
trix-editor {
  border: 1px solid #bbb;
  border-radius: 3px;
  margin: 0;
  padding: 0.4em 0.6em;
  min-height: 5em;
  outline: none;
}

trix-toolbar * {
  box-sizing: border-box;
}
trix-toolbar .trix-button-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  overflow-x: auto;
}
trix-toolbar .trix-button-group {
  display: flex;
  margin-bottom: 10px;
  border: 1px solid #bbb;
  border-top-color: #ccc;
  border-bottom-color: #888;
  border-radius: 3px;
}
trix-toolbar .trix-button-group:not(:first-child) {
  margin-left: 1.5vw;
}
@media (max-width: 768px) {
  trix-toolbar .trix-button-group:not(:first-child) {
    margin-left: 0;
  }
}
trix-toolbar .trix-button-group-spacer {
  flex-grow: 1;
}
@media (max-width: 768px) {
  trix-toolbar .trix-button-group-spacer {
    display: none;
  }
}
trix-toolbar .trix-button {
  position: relative;
  float: left;
  color: rgba(0, 0, 0, 0.6);
  font-size: 0.75em;
  font-weight: 600;
  white-space: nowrap;
  padding: 0 0.5em;
  margin: 0;
  outline: none;
  border: none;
  border-bottom: 1px solid #ddd;
  border-radius: 0;
  background: transparent;
}
trix-toolbar .trix-button:not(:first-child) {
  border-left: 1px solid #ccc;
}
trix-toolbar .trix-button.trix-active {
  background: #cbeefa;
  color: rgb(0, 0, 0);
}
trix-toolbar .trix-button:not(:disabled) {
  cursor: pointer;
}
trix-toolbar .trix-button:disabled {
  color: rgba(0, 0, 0, 0.125);
}
@media (max-width: 768px) {
  trix-toolbar .trix-button {
    letter-spacing: -0.01em;
    padding: 0 0.3em;
  }
}
trix-toolbar .trix-button--icon {
  font-size: inherit;
  width: 2.6em;
  height: 1.6em;
  max-width: calc(0.8em + 4vw);
  text-indent: -9999px;
}
@media (max-width: 768px) {
  trix-toolbar .trix-button--icon {
    height: 2em;
    max-width: calc(0.8em + 3.5vw);
  }
}
trix-toolbar .trix-button--icon::before {
  display: inline-block;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  opacity: 0.6;
  content: "";
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}
@media (max-width: 768px) {
  trix-toolbar .trix-button--icon::before {
    right: 6%;
    left: 6%;
  }
}
trix-toolbar .trix-button--icon.trix-active::before {
  opacity: 1;
}
trix-toolbar .trix-button--icon:disabled::before {
  opacity: 0.125;
}
trix-toolbar .trix-button--icon-attach::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M10.5%2018V7.5c0-2.25%203-2.25%203%200V18c0%204.125-6%204.125-6%200V7.5c0-6.375%209-6.375%209%200V18%22%20stroke%3D%22%23000%22%20stroke-width%3D%222%22%20stroke-miterlimit%3D%2210%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E");
  top: 8%;
  bottom: 4%;
}
trix-toolbar .trix-button--icon-bold::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M6.522%2019.242a.5.5%200%200%201-.5-.5V5.35a.5.5%200%200%201%20.5-.5h5.783c1.347%200%202.46.345%203.24.982.783.64%201.216%201.562%201.216%202.683%200%201.13-.587%202.129-1.476%202.71a.35.35%200%200%200%20.049.613c1.259.56%202.101%201.742%202.101%203.22%200%201.282-.483%202.334-1.363%203.063-.876.726-2.132%201.12-3.66%201.12h-5.89ZM9.27%207.347v3.362h1.97c.766%200%201.347-.17%201.733-.464.38-.291.587-.716.587-1.27%200-.53-.183-.928-.513-1.198-.334-.273-.838-.43-1.505-.43H9.27Zm0%205.606v3.791h2.389c.832%200%201.448-.177%201.853-.497.399-.315.614-.786.614-1.423%200-.62-.22-1.077-.63-1.385-.418-.313-1.053-.486-1.905-.486H9.27Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-italic::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M9%205h6.5v2h-2.23l-2.31%2010H13v2H6v-2h2.461l2.306-10H9V5Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-link::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M18.948%205.258a4.337%204.337%200%200%200-6.108%200L11.217%206.87a.993.993%200%200%200%200%201.41c.392.39%201.027.39%201.418%200l1.623-1.613a2.323%202.323%200%200%201%203.271%200%202.29%202.29%200%200%201%200%203.251l-2.393%202.38a3.021%203.021%200%200%201-4.255%200l-.05-.049a1.007%201.007%200%200%200-1.418%200%20.993.993%200%200%200%200%201.41l.05.049a5.036%205.036%200%200%200%207.091%200l2.394-2.38a4.275%204.275%200%200%200%200-6.072Zm-13.683%2013.6a4.337%204.337%200%200%200%206.108%200l1.262-1.255a.993.993%200%200%200%200-1.41%201.007%201.007%200%200%200-1.418%200L9.954%2017.45a2.323%202.323%200%200%201-3.27%200%202.29%202.29%200%200%201%200-3.251l2.344-2.331a2.579%202.579%200%200%201%203.631%200c.392.39%201.027.39%201.419%200a.993.993%200%200%200%200-1.41%204.593%204.593%200%200%200-6.468%200l-2.345%202.33a4.275%204.275%200%200%200%200%206.072Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-strike::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M6%2014.986c.088%202.647%202.246%204.258%205.635%204.258%203.496%200%205.713-1.728%205.713-4.463%200-.275-.02-.536-.062-.781h-3.461c.398.293.573.654.573%201.123%200%201.035-1.074%201.787-2.646%201.787-1.563%200-2.773-.762-2.91-1.924H6ZM6.432%2010h3.763c-.632-.314-.914-.715-.914-1.273%200-1.045.977-1.739%202.432-1.739%201.475%200%202.52.723%202.617%201.914h2.764c-.05-2.548-2.11-4.238-5.39-4.238-3.145%200-5.392%201.719-5.392%204.316%200%20.363.04.703.12%201.02ZM4%2011a1%201%200%201%200%200%202h15a1%201%200%201%200%200-2H4Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-quote::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M4.581%208.471c.44-.5%201.056-.834%201.758-.995C8.074%207.17%209.201%207.822%2010%208.752c1.354%201.578%201.33%203.555.394%205.277-.941%201.731-2.788%203.163-4.988%203.56a.622.622%200%200%201-.653-.317c-.113-.205-.121-.49.16-.764.294-.286.567-.566.791-.835.222-.266.413-.54.524-.815.113-.28.156-.597.026-.908-.128-.303-.39-.524-.72-.69a3.02%203.02%200%200%201-1.674-2.7c0-.905.283-1.59.72-2.088Zm9.419%200c.44-.5%201.055-.834%201.758-.995%201.734-.306%202.862.346%203.66%201.276%201.355%201.578%201.33%203.555.395%205.277-.941%201.731-2.789%203.163-4.988%203.56a.622.622%200%200%201-.653-.317c-.113-.205-.122-.49.16-.764.294-.286.567-.566.791-.835.222-.266.412-.54.523-.815.114-.28.157-.597.026-.908-.127-.303-.39-.524-.72-.69a3.02%203.02%200%200%201-1.672-2.701c0-.905.283-1.59.72-2.088Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-heading-1::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M21.5%207.5v-3h-12v3H14v13h3v-13h4.5ZM9%2013.5h3.5v-3h-10v3H6v7h3v-7Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-code::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M3.293%2011.293a1%201%200%200%200%200%201.414l4%204a1%201%200%201%200%201.414-1.414L5.414%2012l3.293-3.293a1%201%200%200%200-1.414-1.414l-4%204Zm13.414%205.414%204-4a1%201%200%200%200%200-1.414l-4-4a1%201%200%201%200-1.414%201.414L18.586%2012l-3.293%203.293a1%201%200%200%200%201.414%201.414Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-bullet-list::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M5%207.5a1.5%201.5%200%201%200%200-3%201.5%201.5%200%200%200%200%203ZM8%206a1%201%200%200%201%201-1h11a1%201%200%201%201%200%202H9a1%201%200%200%201-1-1Zm1%205a1%201%200%201%200%200%202h11a1%201%200%201%200%200-2H9Zm0%206a1%201%200%201%200%200%202h11a1%201%200%201%200%200-2H9Zm-2.5-5a1.5%201.5%200%201%201-3%200%201.5%201.5%200%200%201%203%200ZM5%2019.5a1.5%201.5%200%201%200%200-3%201.5%201.5%200%200%200%200%203Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-number-list::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M3%204h2v4H4V5H3V4Zm5%202a1%201%200%200%201%201-1h11a1%201%200%201%201%200%202H9a1%201%200%200%201-1-1Zm1%205a1%201%200%201%200%200%202h11a1%201%200%201%200%200-2H9Zm0%206a1%201%200%201%200%200%202h11a1%201%200%201%200%200-2H9Zm-3.5-7H6v1l-1.5%202H6v1H3v-1l1.667-2H3v-1h2.5ZM3%2017v-1h3v4H3v-1h2v-.5H4v-1h1V17H3Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-undo::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M3%2014a1%201%200%200%200%201%201h6a1%201%200%201%200%200-2H6.257c2.247-2.764%205.151-3.668%207.579-3.264%202.589.432%204.739%202.356%205.174%205.405a1%201%200%200%200%201.98-.283c-.564-3.95-3.415-6.526-6.825-7.095C11.084%207.25%207.63%208.377%205%2011.39V8a1%201%200%200%200-2%200v6Zm2-1Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-redo::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M21%2014a1%201%200%200%201-1%201h-6a1%201%200%201%201%200-2h3.743c-2.247-2.764-5.151-3.668-7.579-3.264-2.589.432-4.739%202.356-5.174%205.405a1%201%200%200%201-1.98-.283c.564-3.95%203.415-6.526%206.826-7.095%203.08-.513%206.534.614%209.164%203.626V8a1%201%200%201%201%202%200v6Zm-2-1Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-decrease-nesting-level::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M5%206a1%201%200%200%201%201-1h12a1%201%200%201%201%200%202H6a1%201%200%200%201-1-1Zm4%205a1%201%200%201%200%200%202h9a1%201%200%201%200%200-2H9Zm-3%206a1%201%200%201%200%200%202h12a1%201%200%201%200%200-2H6Zm-3.707-5.707a1%201%200%200%200%200%201.414l2%202a1%201%200%201%200%201.414-1.414L4.414%2012l1.293-1.293a1%201%200%200%200-1.414-1.414l-2%202Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-button--icon-increase-nesting-level::before {
  background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M5%206a1%201%200%200%201%201-1h12a1%201%200%201%201%200%202H6a1%201%200%200%201-1-1Zm4%205a1%201%200%201%200%200%202h9a1%201%200%201%200%200-2H9Zm-3%206a1%201%200%201%200%200%202h12a1%201%200%201%200%200-2H6Zm-2.293-2.293%202-2a1%201%200%200%200%200-1.414l-2-2a1%201%200%201%200-1.414%201.414L3.586%2012l-1.293%201.293a1%201%200%201%200%201.414%201.414Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E");
}
trix-toolbar .trix-dialogs {
  position: relative;
}
trix-toolbar .trix-dialog {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  font-size: 0.75em;
  padding: 15px 10px;
  background: #fff;
  box-shadow: 0 0.3em 1em #ccc;
  border-top: 2px solid #888;
  border-radius: 5px;
  z-index: 5;
}
trix-toolbar .trix-input--dialog {
  font-size: inherit;
  font-weight: normal;
  padding: 0.5em 0.8em;
  margin: 0 10px 0 0;
  border-radius: 3px;
  border: 1px solid #bbb;
  background-color: #fff;
  box-shadow: none;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}
trix-toolbar .trix-input--dialog.validate:invalid {
  box-shadow: #F00 0px 0px 1.5px 1px;
}
trix-toolbar .trix-button--dialog {
  font-size: inherit;
  padding: 0.5em;
  border-bottom: none;
}
trix-toolbar .trix-dialog--link {
  max-width: 600px;
}
trix-toolbar .trix-dialog__link-fields {
  display: flex;
  align-items: baseline;
}
trix-toolbar .trix-dialog__link-fields .trix-input {
  flex: 1;
}
trix-toolbar .trix-dialog__link-fields .trix-button-group {
  flex: 0 0 content;
  margin: 0;
}

trix-editor [data-trix-mutable]:not(.attachment__caption-editor) {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

trix-editor [data-trix-mutable] ::-moz-selection, trix-editor [data-trix-mutable]::-moz-selection,
trix-editor [data-trix-cursor-target]::-moz-selection {
  background: none;
}
trix-editor [data-trix-mutable] ::selection, trix-editor [data-trix-mutable]::selection,
trix-editor [data-trix-cursor-target]::selection {
  background: none;
}

trix-editor [data-trix-mutable].attachment__caption-editor:focus::-moz-selection {
  background: highlight;
}
trix-editor [data-trix-mutable].attachment__caption-editor:focus::selection {
  background: highlight;
}

trix-editor [data-trix-mutable].attachment.attachment--file {
  box-shadow: 0 0 0 2px highlight;
  border-color: transparent;
}
trix-editor [data-trix-mutable].attachment img {
  box-shadow: 0 0 0 2px highlight;
}
trix-editor .attachment {
  position: relative;
}
trix-editor .attachment:hover {
  cursor: default;
}
trix-editor .attachment--preview .attachment__caption:hover {
  cursor: text;
}
trix-editor .attachment__progress {
  position: absolute;
  z-index: 1;
  height: 20px;
  top: calc(50% - 10px);
  left: 5%;
  width: 90%;
  opacity: 0.9;
  transition: opacity 200ms ease-in;
}
trix-editor .attachment__progress[value="100"] {
  opacity: 0;
}
trix-editor .attachment__caption-editor {
  display: inline-block;
  width: 100%;
  margin: 0;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
  color: inherit;
  text-align: center;
  vertical-align: top;
  border: none;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}
trix-editor .attachment__toolbar {
  position: absolute;
  z-index: 1;
  top: -0.9em;
  left: 0;
  width: 100%;
  text-align: center;
}
trix-editor .trix-button-group {
  display: inline-flex;
}
trix-editor .trix-button {
  position: relative;
  float: left;
  color: #666;
  white-space: nowrap;
  font-size: 80%;
  padding: 0 0.8em;
  margin: 0;
  outline: none;
  border: none;
  border-radius: 0;
  background: transparent;
}
trix-editor .trix-button:not(:first-child) {
  border-left: 1px solid #ccc;
}
trix-editor .trix-button.trix-active {
  background: #cbeefa;
}
trix-editor .trix-button:not(:disabled) {
  cursor: pointer;
}
trix-editor .trix-button--remove {
  text-indent: -9999px;
  display: inline-block;
  padding: 0;
  outline: none;
  width: 1.8em;
  height: 1.8em;
  line-height: 1.8em;
  border-radius: 50%;
  background-color: #fff;
  border: 2px solid highlight;
  box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.25);
}
trix-editor .trix-button--remove::before {
  display: inline-block;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  opacity: 0.7;
  content: "";
  background-image: url("data:image/svg+xml,%3Csvg%20height%3D%2224%22%20width%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M19%206.41%2017.59%205%2012%2010.59%206.41%205%205%206.41%2010.59%2012%205%2017.59%206.41%2019%2012%2013.41%2017.59%2019%2019%2017.59%2013.41%2012z%22%2F%3E%3Cpath%20d%3D%22M0%200h24v24H0z%22%20fill%3D%22none%22%2F%3E%3C%2Fsvg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 90%;
}
trix-editor .trix-button--remove:hover {
  border-color: #333;
}
trix-editor .trix-button--remove:hover::before {
  opacity: 1;
}
trix-editor .attachment__metadata-container {
  position: relative;
}
trix-editor .attachment__metadata {
  position: absolute;
  left: 50%;
  top: 2em;
  transform: translate(-50%, 0);
  max-width: 90%;
  padding: 0.1em 0.6em;
  font-size: 0.8em;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 3px;
}
trix-editor .attachment__metadata .attachment__name {
  display: inline-block;
  max-width: 100%;
  vertical-align: bottom;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
trix-editor .attachment__metadata .attachment__size {
  margin-left: 0.2em;
  white-space: nowrap;
}

.trix-content {
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: break-word;
}
.trix-content * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
.trix-content h1 {
  font-size: 1.2em;
  line-height: 1.2;
}
.trix-content blockquote {
  border: 0 solid #ccc;
  border-left-width: 0.3em;
  margin-left: 0.3em;
  padding-left: 0.6em;
}
.trix-content [dir=rtl] blockquote,
.trix-content blockquote[dir=rtl] {
  border-width: 0;
  border-right-width: 0.3em;
  margin-right: 0.3em;
  padding-right: 0.6em;
}
.trix-content li {
  margin-left: 1em;
}
.trix-content [dir=rtl] li {
  margin-right: 1em;
}
.trix-content pre {
  display: inline-block;
  width: 100%;
  vertical-align: top;
  font-family: monospace;
  font-size: 0.9em;
  padding: 0.5em;
  white-space: pre;
  background-color: #eee;
  overflow-x: auto;
}
.trix-content img {
  max-width: 100%;
  height: auto;
}
.trix-content .attachment {
  display: inline-block;
  position: relative;
  max-width: 100%;
}
.trix-content .attachment a {
  color: inherit;
  text-decoration: none;
}
.trix-content .attachment a:hover, .trix-content .attachment a:visited:hover {
  color: inherit;
}
.trix-content .attachment__caption {
  text-align: center;
}
.trix-content .attachment__caption .attachment__name + .attachment__size::before {
  content: " •";
}
.trix-content .attachment--preview {
  width: 100%;
  text-align: center;
}
.trix-content .attachment--preview .attachment__caption {
  color: #666;
  font-size: 0.9em;
  line-height: 1.2;
}
.trix-content .attachment--file {
  color: #333;
  line-height: 1;
  margin: 0 2px 2px 2px;
  padding: 0.4em 1em;
  border: 1px solid #bbb;
  border-radius: 5px;
}
.trix-content .attachment-gallery {
  display: flex;
  flex-wrap: wrap;
  position: relative;
}
.trix-content .attachment-gallery .attachment {
  flex: 1 0 33%;
  padding: 0 0.5em;
  max-width: 33%;
}
.trix-content .attachment-gallery.attachment-gallery--2 .attachment, .trix-content .attachment-gallery.attachment-gallery--4 .attachment {
  flex-basis: 50%;
  max-width: 50%;
}
/*
 * Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
 * the trix-editor content (whether displayed or under editing). Feel free to incorporate this
 * inclusion directly in any other asset bundle and remove this file.
 *

*/

/*
 * We need to override trix.css’s image gallery styles to accommodate the
 * <action-text-attachment> element we wrap around attachments. Otherwise,
 * images in galleries will be squished by the max-width: 33%; rule.
*/
.trix-content .attachment-gallery > action-text-attachment,
.trix-content .attachment-gallery > .attachment {
  flex: 1 0 33%;
  padding: 0 0.5em;
  max-width: 33%;
}

.trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment,
.trix-content .attachment-gallery.attachment-gallery--2 > .attachment, .trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment,
.trix-content .attachment-gallery.attachment-gallery--4 > .attachment {
  flex-basis: 50%;
  max-width: 50%;
}

.trix-content action-text-attachment .attachment {
  padding: 0 !important;
  max-width: 100% !important;
}
/* ===========================================
   Proflemsa CRM — Dynamics 365 / Fluent shell
   Bootstrap 5.3 + Dark Mode + Mobile First
   Neutros Fluent + acento navy marca (sin #0078D4)
   =========================================== */

/* ── Light theme — Dynamics Fluent + navy ── */
:root,
[data-bs-theme="light"] {
  --crm-bg:              #f3f2f1;
  --crm-surface:         #ffffff;
  --crm-surface-alt:     #faf9f8;
  --crm-border:          #edebe9;
  --crm-border-light:    #f3f2f1;
  --crm-text:            #242424;
  --crm-text-secondary:  #605e5c;
  --crm-text-muted:      #8a8886;
  --crm-accent:          #1e3a5f;
  --crm-accent-hover:    #152c47;
  --crm-accent-light:    #e8eef4;
  --crm-hover:           #f3f2f1;
  --crm-sidebar-bg:      #00112c;
  --crm-sidebar-border:  rgba(120, 170, 220, 0.14);
  --crm-sidebar-text:    rgba(230, 240, 250, 0.90);
  --crm-sidebar-text-muted: rgba(200, 220, 240, 0.50);
  --crm-sidebar-hover:   rgba(255, 255, 255, 0.08);
  --crm-sidebar-active-bg: rgba(91, 138, 181, 0.25);
  --crm-sidebar-active-text: #8ec5f0;
  --crm-sidebar-accent:  #5b8ab5;
  --crm-topbar-bg:       #ffffff;
  --crm-shadow:          0 0 0 1px rgba(0, 0, 0, 0.04);
  --crm-shadow-md:       0 1px 4px rgba(0, 0, 0, 0.08);
  --crm-shadow-lg:       0 4px 12px rgba(0, 0, 0, 0.10);
  --crm-kanban-col-bg:   #f3f2f1;
  --crm-trix-toolbar-bg: #f3f2f1;
  --crm-spinner-bg:      rgba(255,255,255,0.88);
  --crm-scroll-thumb:    #c8c6c4;
  --crm-scroll-track:    transparent;
  --crm-bottleneck:      #b45309;
  --crm-bottleneck-bg:   rgba(180, 83, 9, 0.10);
  --crm-danger:          #b91c1c;
  --crm-danger-hover:    #7f1313;
  --crm-warning:         #b45309;
  --crm-warning-hover:   #8a3f06;
  --crm-success:         #15803d;
  --crm-success-hover:   #0f5e2e;
  --crm-success-bg:      rgba(21, 128, 61, 0.10);
  --crm-info:            #0e6e8a;
  --crm-info-hover:      #0a556e;

  /* Shell — radios Fluent / Dynamics */
  --crm-sidebar-width:     248px;
  --crm-sidebar-collapsed: 64px;
  --crm-topbar-height:     48px;
  --crm-native-nav-height: 3.95rem; /* min-height 3.5rem + padding vert. 0.45rem */
  --crm-radius:            8px;
  --crm-radius-sm:         4px;
  --crm-radius-xs:         2px;
}

/* ── Dark theme — slate profundo + navy acero ──── */
[data-bs-theme="dark"] {
  --crm-bg:              #0c1017;
  --crm-surface:         #151a22;
  --crm-surface-alt:     #1c222c;
  --crm-border:          #2a3340;
  --crm-border-light:    #1a2029;
  --crm-text:            #e2e8f0;
  --crm-text-secondary:  #94a3b8;
  --crm-text-muted:      #64748b;
  --crm-accent:          #5b8ab5;
  --crm-accent-hover:    #7aa3c4;
  --crm-accent-light:    rgba(91, 138, 181, 0.14);
  --crm-hover:           #1c222c;
  --crm-sidebar-bg:      #00112c;
  --crm-sidebar-border:  rgba(120, 170, 220, 0.12);
  --crm-sidebar-text:    rgba(230, 240, 250, 0.88);
  --crm-sidebar-text-muted: rgba(200, 220, 240, 0.48);
  --crm-sidebar-hover:   rgba(255, 255, 255, 0.07);
  --crm-sidebar-active-bg: rgba(91, 138, 181, 0.22);
  --crm-sidebar-active-text: #8ec5f0;
  --crm-sidebar-accent:  #5b8ab5;
  --crm-topbar-bg:       #151a22;
  --crm-shadow:          0 0 0 1px rgba(255, 255, 255, 0.04);
  --crm-shadow-md:       0 1px 4px rgba(0, 0, 0, 0.35);
  --crm-shadow-lg:       0 4px 12px rgba(0, 0, 0, 0.45);
  --crm-kanban-col-bg:   #1c222c;
  --crm-trix-toolbar-bg: #1c222c;
  --crm-spinner-bg:      rgba(12, 16, 23, 0.88);
  --crm-scroll-thumb:    #3a4554;
  --crm-scroll-track:    transparent;
  --crm-bottleneck:      #f59e0b;
  --crm-bottleneck-bg:   rgba(245, 158, 11, 0.14);
  --crm-danger:          #f87171;
  --crm-danger-hover:    #f9a8a8;
  --crm-warning:         #f59e0b;
  --crm-warning-hover:   #fbb45a;
  --crm-success:         #4ade80;
  --crm-success-hover:   #6ee897;
  --crm-success-bg:      rgba(74, 222, 128, 0.12);
  --crm-info:            #5ec4d8;
  --crm-info-hover:      #7dd4e6;
}

/* ── Bootstrap dark-mode overrides ────────── */
[data-bs-theme="dark"] .card {
  background-color: var(--crm-surface);
  border-color: var(--crm-border);
}
[data-bs-theme="dark"] .form-control {
  background-color: var(--crm-surface-alt);
  border-color: var(--crm-border);
  color: var(--crm-text);
}
[data-bs-theme="dark"] .form-control:focus {
  background-color: var(--crm-surface-alt);
  border-color: var(--crm-accent);
  color: var(--crm-text);
}
[data-bs-theme="dark"] .form-select {
  background-color: var(--crm-surface-alt);
  border-color: var(--crm-border);
  color: var(--crm-text);
}
[data-bs-theme="dark"] .dropdown-menu {
  background-color: var(--crm-surface);
  border-color: var(--crm-border);
}
[data-bs-theme="dark"] .dropdown-item:hover {
  background-color: var(--crm-hover);
  color: var(--crm-text);
}
[data-bs-theme="dark"] .dropdown-item {
  color: var(--crm-text-secondary);
}
[data-bs-theme="dark"] .btn-light {
  background-color: var(--crm-surface-alt);
  border-color: var(--crm-border);
  color: var(--crm-text-secondary);
}
[data-bs-theme="dark"] .btn-light:hover {
  background-color: var(--crm-hover);
  color: var(--crm-text);
}
[data-bs-theme="dark"] .list-group-item {
  background-color: transparent;
  border-color: var(--crm-border);
  color: var(--crm-text);
}
[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--crm-border);
  --bs-table-color: var(--crm-text);
  --bs-table-striped-bg: var(--crm-surface-alt);
  --bs-table-hover-bg: var(--crm-hover);
}
[data-bs-theme="dark"] .modal-content {
  background-color: var(--crm-surface);
  border-color: var(--crm-border);
}
[data-bs-theme="dark"] .progress {
  background-color: var(--crm-surface-alt);
}
[data-bs-theme="dark"] .offcanvas {
  background-color: var(--crm-surface);
}
[data-bs-theme="dark"] .badge.bg-success-subtle {
  background-color: rgba(25, 135, 84, 0.15) !important;
  color: #5cd6a0 !important;
}
[data-bs-theme="dark"] .badge.bg-danger-subtle {
  background-color: rgba(220, 53, 69, 0.15) !important;
  color: #f58da0 !important;
}

/* ── Base — Segoe UI / Dynamics ───────────── */
.admin-body {
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--crm-bg);
  font-family: "Segoe UI", "Segoe UI Variable", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--crm-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════
   Sales Cycle — detail view (content area only)
   Sidebar y topbar permanecen visibles.
   ═══════════════════════════════════════════ */

.admin-main:has(.sales-cycles-shell),
.admin-main:has(.repair-cycles-shell),
.admin-main:has(.customer-follow-up-shell) {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--crm-topbar-height, 48px));
}

.admin-content:has(.sales-cycles-shell),
.admin-content:has(.repair-cycles-shell),
.admin-content:has(.customer-follow-up-shell) {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.admin-content:has(.sc-detail-view.is-open) {
  overflow: hidden;
}

.sales-cycles-shell,
.repair-cycles-shell,
.customer-follow-up-shell {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.admin-content:has(.sc-detail-view.is-open) .sales-cycles-page,
.admin-content:has(.sc-detail-view.is-open) .repair-cycles-page {
  display: none;
}

.sales-cycles-page,
.repair-cycles-page {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
}

.sc-detail-view {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  background: var(--crm-bg);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  box-shadow: var(--crm-shadow-md);
}

.sc-detail-view.is-open {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sc-detail-view__shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--crm-bg);
  border-radius: inherit;
}

/* ── Header ── */
.sc-detail-header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--crm-border);
  background: var(--crm-surface);
  box-shadow: var(--crm-shadow);
}

.sc-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.4rem 0.85rem 0.4rem 0.65rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background: var(--crm-surface-alt);
  color: var(--crm-accent);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.sc-detail-back:hover,
.sc-detail-back:focus-visible {
  background: var(--crm-hover);
  border-color: color-mix(in srgb, var(--crm-accent) 30%, var(--crm-border));
  color: var(--crm-accent);
}

.sc-detail-back__label {
  white-space: nowrap;
}

.sc-detail-header__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
}

.sc-detail-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--crm-text);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.sc-detail-stage-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--crm-radius-sm);
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  border: 1px solid color-mix(in srgb, var(--crm-accent) 20%, transparent);
}

.sc-detail-stage-badge[hidden],
.sc-detail-stage-badge:empty {
  display: none;
}

.sc-detail-case-id {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--crm-text-muted);
  background: var(--crm-surface-alt);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  padding: 0.2rem 0.55rem;
  line-height: 1.2;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-detail-case-id i {
  color: var(--crm-accent);
  font-size: 0.7rem;
}

.sc-detail-case-id[hidden] {
  display: none;
}

.kanban-card-case-number {
  color: var(--crm-text-muted);
  opacity: 0.85;
}

.sc-detail-header-save {
  min-height: 2.5rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Tabs ── */
.sc-detail-tabs-wrap {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--crm-border);
  background: var(--crm-surface-alt);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  scroll-padding-inline: 0.75rem;
}

.sc-detail-tabs-wrap::-webkit-scrollbar {
  display: none;
}

.sc-detail-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  border: none;
  min-width: min-content;
  max-width: 1200px;
  margin-inline: auto;
}

.sc-detail-tabs .nav-item {
  flex: 0 0 auto;
}

.sc-detail-tabs .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.75rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--crm-text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.sc-detail-tabs .nav-link:hover {
  color: var(--crm-text);
  background: var(--crm-hover);
}

.sc-detail-tabs .nav-link.active {
  color: var(--crm-accent);
  background: transparent;
  border-bottom-color: var(--crm-accent);
}

.sales-cycle-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 999px;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
}

/* ── Body ── */
.sc-detail-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* none: evita el pull-to-refresh accidental con el formulario sucio */
  overscroll-behavior-y: none;
  padding: 1rem;
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  /* Footer in-flow (siempre visible): basta respiro inferior, sin despeje extra */
  padding-bottom: calc(1.75rem + env(safe-area-inset-bottom, 0px));
}

.sc-detail-body__inner {
  max-width: 1200px;
  margin: 0 auto;
}

.sc-detail-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.sc-detail-form-grid__full {
  grid-column: 1 / -1;
}

.sc-detail-view .sales-cycle-tab-content {
  padding: 0;
}

.sales-cycle-tab-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sales-cycle-tab-stack > .sales-cycle-form-section:last-child {
  margin-bottom: 0;
}

.sales-cycle-tab-placeholder,
.sales-cycle-tab-stack > p.text-muted:only-child {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 8rem;
  margin: 0;
  padding: 2rem 1.25rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--crm-text-muted);
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  box-shadow: var(--crm-shadow);
}

.sales-cycle-tab-empty {
  font-size: 0.88rem;
  color: var(--crm-text-muted);
}

.sales-cycle-tab-empty-state {
  text-align: center;
  padding: 1.75rem 1rem;
  color: var(--crm-text-muted);
}
.sales-cycle-tab-empty-state i {
  display: block;
  font-size: 2.25rem;
  margin-bottom: 0.75rem;
  opacity: 0.35;
}
.sales-cycle-tab-empty-state p {
  margin: 0;
  color: var(--crm-text-secondary);
  font-weight: 600;
}
.sales-cycle-tab-empty-state .small {
  font-weight: 400;
  color: var(--crm-text-muted);
}

/* Sales cycle delivery proof tab */
.sc-delivery-proof__card {
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background: color-mix(in srgb, var(--crm-success, #166534) 8%, var(--crm-surface));
  padding: 1rem 1.1rem 1.15rem;
}

.sc-delivery-proof__card--warning {
  background: color-mix(in srgb, var(--crm-warning) 10%, var(--crm-surface));
  border-color: color-mix(in srgb, var(--crm-warning) 35%, var(--crm-border));
}

.sc-delivery-proof__card--warning .sc-delivery-proof__title {
  color: var(--crm-warning);
}

.sc-delivery-proof__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.sc-delivery-proof__title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--crm-text-secondary);
}

.sc-delivery-proof__when {
  font-size: 0.8rem;
  color: var(--crm-text-muted);
  white-space: nowrap;
}

.sc-delivery-proof__fields {
  margin: 0 0 1rem;
}

.sc-delivery-proof__field {
  display: grid;
  gap: 0.2rem;
}

.sc-delivery-proof__field dt {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--crm-text-muted);
  margin: 0;
}

.sc-delivery-proof__field dd {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--crm-text);
}

.sc-delivery-proof__signature-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--crm-text-muted);
  margin: 0 0 0.45rem;
}

.sc-delivery-proof__signature {
  display: block;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background: #fff;
  overflow: hidden;
  max-width: 100%;
}

.sc-delivery-proof__signature--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  background: var(--crm-surface);
  pointer-events: none;
}

.sc-delivery-proof__signature-img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #fff;
}

[data-bs-theme="dark"] .sc-delivery-proof__signature,
[data-bs-theme="dark"] .sc-delivery-proof__signature-img {
  background: #f8fafc;
}

/* Sales cycle activity timeline (Historial tab) */
.sc-activity-timeline__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sc-activity-timeline__item {
  position: relative;
  display: grid;
  grid-template-columns: 1.35rem 1fr;
  gap: 0.75rem;
  padding: 0.65rem 0 0.65rem 0.15rem;
}

.sc-activity-timeline__item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 0.6rem;
  top: 1.7rem;
  bottom: -0.15rem;
  width: 2px;
  background: var(--crm-border);
}

.sc-activity-timeline__marker {
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.05rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--crm-accent) 14%, var(--crm-surface));
  border: 1px solid var(--crm-border);
  color: var(--crm-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  z-index: 1;
}

.sc-movement-action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}

.sc-movement-action i {
  color: var(--crm-accent);
  font-size: 0.78rem;
}

.sc-movement-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--crm-accent) 14%, var(--crm-surface));
  color: var(--crm-accent);
  border: 1px solid var(--crm-border);
  font-size: 0.75rem;
}

.sc-activity-timeline__body {
  min-width: 0;
}

.sc-activity-timeline__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
}

.sc-activity-timeline__action {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--crm-text);
}

.sc-activity-timeline__time {
  font-size: 0.75rem;
  color: var(--crm-text-muted);
  white-space: nowrap;
}

.sc-activity-timeline__summary {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--crm-text);
  line-height: 1.35;
}

.sc-activity-timeline__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--crm-text-muted);
}

.sc-activity-timeline__user i {
  margin-right: 0.25rem;
  opacity: 0.8;
}

.sales-cycle-tab-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sales-cycle-field-hint {
  font-size: 0.78rem;
  color: var(--crm-text-muted);
}

.sales-cycle-inline-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--crm-text-secondary);
}
.sales-cycle-inline-hint i {
  color: var(--crm-accent);
}

.sales-cycle-kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--crm-border-light);
}
.sales-cycle-kv:last-child {
  border-bottom: none;
}
.sales-cycle-kv--total {
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--crm-border);
  border-bottom: none;
}
.sales-cycle-kv__label {
  font-size: 0.82rem;
  color: var(--crm-text-muted);
}
.sales-cycle-kv__value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--crm-text);
  text-align: right;
}
.sales-cycle-kv--total .sales-cycle-kv__label,
.sales-cycle-kv--total .sales-cycle-kv__value {
  font-weight: 700;
  color: var(--crm-accent);
}

.sales-cycle-quote-folio {
  font-size: 1rem;
  font-weight: 700;
  color: var(--crm-text);
}
.sales-cycle-quote-meta {
  font-size: 0.82rem;
  color: var(--crm-text-muted);
}
.sales-cycle-quote-notes {
  padding: 0.75rem;
  border-radius: var(--crm-radius-xs);
  background: color-mix(in srgb, var(--crm-bg) 55%, var(--crm-surface));
  border: 1px solid var(--crm-border-light);
  font-size: 0.88rem;
  color: var(--crm-text-secondary);
}
.sales-cycle-quote-table thead th {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--crm-text-muted);
  border-bottom-color: var(--crm-border-light);
}
.sales-cycle-quote-items {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.sales-cycle-quote-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--crm-border-light);
  font-size: 0.88rem;
}
.sales-cycle-quote-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.sales-cycle-quote-item:first-child {
  padding-top: 0;
}

.sales-cycle-order-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 1.5rem 1rem;
  border: 2px dashed color-mix(in srgb, var(--crm-accent) 35%, var(--crm-border));
  border-radius: var(--crm-radius-xs);
  background: color-mix(in srgb, var(--crm-accent) 6%, var(--crm-surface));
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.sales-cycle-order-dropzone:hover,
.sales-cycle-order-dropzone:focus-within {
  border-color: var(--crm-accent);
  background: color-mix(in srgb, var(--crm-accent) 10%, var(--crm-surface));
}
.sales-cycle-order-dropzone__icon {
  font-size: 2rem;
  color: var(--crm-accent);
  margin-bottom: 0.25rem;
}
.sales-cycle-order-dropzone__title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--crm-text);
}
.sales-cycle-order-dropzone__hint {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--crm-text-muted);
}

.sales-cycle-order-dropzone--active {
  border-color: var(--crm-accent);
  background: color-mix(in srgb, var(--crm-accent) 12%, var(--crm-surface));
}
.sales-cycle-order-pending {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem;
  border: 1px solid var(--crm-border-light);
  border-radius: var(--crm-radius-xs);
  background: color-mix(in srgb, var(--crm-bg) 40%, var(--crm-surface));
}

.sales-cycle-order-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sales-cycle-order-doc {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem;
  border: 1px solid var(--crm-border-light);
  border-radius: var(--crm-radius-xs);
  background: color-mix(in srgb, var(--crm-bg) 40%, var(--crm-surface));
}
.sales-cycle-order-doc__icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--crm-radius-xs);
  background: color-mix(in srgb, #e63946 12%, var(--crm-surface));
  color: #e63946;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sales-cycle-order-doc__folio {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--crm-text);
}
.sales-cycle-order-doc__meta {
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}
.sales-cycle-order-doc__actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
  margin-left: auto;
}
.sales-cycle-order-doc__actions .sales-cycle-btn-action {
  min-height: 2.35rem;
  min-width: 2.35rem;
  padding: 0.35rem 0.5rem;
}

.sales-cycle-invoice-dropzone {
  min-height: 8.5rem;
}
.sales-cycle-invoice-pair-form .sales-cycle-tab-actions {
  display: flex;
  gap: 0.5rem;
}

.sales-cycle-list-card {
  padding: 0.85rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--crm-border-light);
  border-radius: var(--crm-radius-xs);
  background: color-mix(in srgb, var(--crm-bg) 35%, var(--crm-surface));
}
.sales-cycle-list-card:last-child {
  margin-bottom: 0;
}
.sales-cycle-list-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.sales-cycle-list-card__title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--crm-text);
}
.sales-cycle-list-card__delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #e63946;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sales-cycle-list-card__meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  color: var(--crm-text-secondary);
}
.sales-cycle-list-card__body {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--crm-text-secondary);
  line-height: 1.45;
}
.sales-cycle-list-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.35rem;
  border-top: 1px solid var(--crm-border-light);
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

/* ── Vista de solo lectura del ciclo de venta (show) ── */
.sc-view-item {
  padding: 0.85rem;
  border: 1px solid var(--crm-border-light);
  border-radius: var(--crm-radius-xs);
  background: color-mix(in srgb, var(--crm-bg) 35%, var(--crm-surface));
}
.sc-view-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.sc-view-item__when {
  font-size: 0.78rem;
  color: var(--crm-text-muted);
  white-space: nowrap;
}
.sc-view-item__body {
  font-size: 0.85rem;
  color: var(--crm-text-secondary);
  line-height: 1.45;
}
.sc-view-rich-text {
  font-size: 0.9rem;
  color: var(--crm-text-secondary);
  line-height: 1.5;
}

/* ── Agenda events (tab Agenda del ciclo de venta) ── */
.sales-cycle-tab-actions--inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.agenda-event-card--completed .sales-cycle-list-card__title {
  text-decoration: line-through;
  color: var(--crm-text-muted);
  opacity: 0.85;
}
.agenda-event-card--completed {
  background: color-mix(in srgb, var(--crm-surface) 60%, var(--crm-bg));
  opacity: 0.92;
}
.agenda-event-card__status {
  font-size: 0.72rem;
  padding: 0.3rem 0.55rem;
}
.agenda-event-card__toggle {
  min-height: 2.25rem;
}


.sc-detail-view .note-card {
  border-radius: var(--crm-radius-xs) !important;
  border: 1px solid var(--crm-border-light) !important;
  box-shadow: none !important;
  padding: 0.85rem !important;
  margin-bottom: 0.5rem !important;
}
.sc-detail-view .note-card:last-child {
  margin-bottom: 0 !important;
}
.sc-detail-view .note-card h5 {
  font-size: 0.92rem !important;
}

.sales-cycle-check {
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  padding: 0.35rem 0;
}

.sales-cycle-geo-btn {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  z-index: 5;
  min-height: 2.25rem;
}
.sales-cycle-geo-spinner {
  position: absolute;
  top: 50%;
  right: 0.65rem;
  transform: translateY(-50%);
  z-index: 5;
}

/* Legacy tab panel — replaced by tab-stack */
.sales-cycle-tab-panel {
  overflow: visible;
  max-height: none;
}

.sales-cycle-form-section {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  margin-bottom: 0.75rem;
  overflow: visible;
  box-shadow: var(--crm-shadow);
  position: relative;
  z-index: 0;
}

.sales-cycle-form-section:focus-within {
  z-index: 5;
}

.sales-cycle-search-wrap {
  position: relative;
  z-index: 1;
}

.sales-cycle-search-wrap:focus-within {
  z-index: 10;
}

.sales-cycle-form-section:last-child {
  margin-bottom: 0;
}

.sales-cycle-form-section__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
  border-bottom: 1px solid var(--crm-border-light);
  background: var(--crm-surface-alt);
}

.sales-cycle-form-section__title i {
  color: var(--crm-accent);
  font-size: 0.85rem;
}

.sales-cycle-form-section__body {
  padding: 1rem;
}

.sales-cycle-form-section__body .crm-field-label {
  display: block;
  margin-bottom: 0.35rem;
}

.sc-detail-view .form-control.sales-cycle-input,
.sc-detail-view .form-select.sales-cycle-input {
  min-height: 2.75rem;
  padding: 0.55rem 0.85rem;
  font-size: 1rem;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface);
  color: var(--crm-text);
  box-shadow: none;
  touch-action: manipulation;
}

.sales-cycle-input:focus,
.sc-detail-view .form-control.sales-cycle-input:focus,
.sc-detail-view .form-select.sales-cycle-input:focus {
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crm-accent) 18%, transparent);
}

.sales-cycle-stage-display {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface-alt);
  color: var(--crm-text);
  font-size: 0.9375rem;
  font-weight: 600;
}

.sales-cycle-input-group .input-group-text {
  min-height: 2.75rem;
  border-radius: var(--crm-radius-xs) 0 0 var(--crm-radius-xs);
  border-color: var(--crm-border);
  background: var(--crm-surface-alt);
  color: var(--crm-text-muted);
  font-weight: 600;
}

.sales-cycle-input-group .form-control {
  min-height: 2.75rem;
  border-radius: 0 var(--crm-radius-xs) var(--crm-radius-xs) 0;
  border-color: var(--crm-border);
  font-size: 1rem;
}

.sales-cycle-trix,
.sc-detail-view .trix-content.sales-cycle-trix {
  min-height: 6rem;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface);
  box-shadow: none;
}

.crm-search-results,
.sales-cycle-contact-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1070;
  max-height: min(16.25rem, 50dvh); /* ~5 filas visibles + scroll, sin tapar pantallas bajas */
  overflow-y: auto;
  margin-top: 0.25rem;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface);
  box-shadow: var(--crm-shadow-md);
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* SAT autocomplete — solo hints táctiles; conserva estilos inline del markup */
.sat-autocomplete-results,
[data-service-parts-form-target="results"].list-group {
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

[data-service-parts-form-target="results"].list-group {
  max-height: 16.25rem;
  overflow-y: auto;
}

[data-service-parts-form-target="results"] .list-group-item {
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

/* Escapa overflow de paneles/modales: el JS porta este nodo a document.body */
.crm-search-results.crm-search-results--fixed {
  position: fixed !important;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
  margin-top: 0;
  max-height: min(16.25rem, 40vh);
  z-index: 2000;
}

.crm-search-results .list-group-item,
.sales-cycle-contact-results .list-group-item,
.sat-autocomplete-results .list-group-item {
  background-color: var(--crm-surface);
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

.crm-search-results .list-group-item:hover,
.crm-search-results .list-group-item.active,
.sales-cycle-contact-results .list-group-item:hover,
.sales-cycle-contact-results .list-group-item.active {
  background-color: var(--crm-hover);
}

/* Ítem de resultado: clave mono + descripción truncada + meta de precios compacta */
.crm-search-results .crm-search-results__item {
  padding: 0.45rem 0.75rem;
}

.crm-search-results__main {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}

.crm-search-results__key {
  flex: 0 0 auto;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--bs-font-monospace);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--crm-accent);
  background: var(--crm-hover);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  padding: 0.05rem 0.35rem;
  white-space: nowrap;
}

.crm-search-results__desc {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-search-results__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.75rem;
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--crm-text-muted);
}

.crm-search-results__price {
  font-weight: 600;
  color: var(--crm-text);
  font-variant-numeric: tabular-nums;
}

[data-bs-theme="dark"] .crm-search-results .list-group-item,
[data-bs-theme="dark"] .sales-cycle-contact-results .list-group-item,
[data-bs-theme="dark"] .sat-autocomplete-results .list-group-item {
  background-color: var(--crm-surface);
}

/* Quote item modal — sin transform para no crear containing block del dropdown */
#quoteItemModal.modal {
  overflow: visible;
}

#quoteItemModal .modal-dialog,
#quoteItemModal.modal.fade .modal-dialog,
#quoteItemModal.modal.show .modal-dialog {
  transform: none;
}

#quoteItemModal .modal-dialog,
#quoteItemModal .quote-item-modal__content,
#quoteItemModal .quote-item-modal__body {
  overflow: visible;
}

#quoteItemModal .quote-item-modal__body .position-relative {
  z-index: 5;
}

#quoteItemModal .crm-search-results {
  z-index: 1085;
  max-height: 12.5rem;
}

/* Quote items block — elevar toda la sección sobre Observaciones/Totales hermanos
   (el z-index interno de .quote-item-row no basta: el dropdown desborda la card
   y la col-12 siguiente pinta encima en el mismo stacking context del form.row) */
[data-quote-form-target="itemsBlock"] {
  position: relative;
  z-index: 5;
  overflow: visible;
}

[data-quote-form-target="itemsBlock"] > .card {
  overflow: visible;
}

/* Quote items panel — bloque Artículos denso (new/edit) */
.crm-quote-items-panel {
  padding: 0;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border) !important;
  border-radius: var(--crm-radius) !important;
  box-shadow: none !important;
}

.crm-quote-items-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--crm-border);
  background: var(--crm-surface-alt);
}

.crm-quote-items-panel__title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--crm-text);
}

.crm-quote-items-panel__list {
  max-height: min(28rem, 55vh);
  overflow-y: auto;
  overflow-x: auto;
  overscroll-behavior: contain;
}

.crm-quote-items-panel__empty {
  padding: 0.85rem 0.75rem;
  font-size: 0.85rem;
  text-align: center;
}

/* Quote item row — apilamiento entre filas de ítems + dropdown + densidad */
.quote-item-row,
.crm-quote-item-row {
  position: relative;
  z-index: 10;
  overflow: visible;
  padding: 0.45rem 0.65rem 0.55rem;
  margin: 0;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--crm-border);
  background: var(--crm-surface);
}

.crm-quote-item-row:nth-child(even) {
  background: color-mix(in srgb, var(--crm-surface-alt, var(--crm-bg)) 55%, var(--crm-surface));
}

.crm-quote-item-row:last-child {
  border-bottom: 0;
}

.crm-quote-item-row__main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.4rem 0.5rem;
  align-items: center;
}

.crm-quote-item-row__index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.5rem;
  padding: 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--crm-text-secondary);
  background: var(--crm-surface-alt, var(--crm-bg));
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
}

.crm-quote-item-row__product {
  min-width: 0;
}

/* Con producto asignado la clave/descripción viven en el grid; ocultar búsqueda duplicada */
.crm-quote-item-row:has([data-quote-item-target="extraFields"]:not(.d-none)) .crm-quote-item-row__product {
  display: none;
}

.crm-quote-item-row:has([data-quote-item-target="extraFields"]:not(.d-none)) .crm-quote-item-row__main {
  grid-template-columns: auto auto;
  justify-content: space-between;
}

.crm-quote-item-row__remove {
  flex-shrink: 0;
}

.crm-quote-item-row__label {
  display: block;
  margin: 0 0 0.12rem;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
}

.crm-quote-item-row__control {
  font-size: 0.8rem;
  min-height: 1.85rem;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.crm-quote-item-row__control--desc {
  resize: vertical;
  min-height: 1.85rem;
  max-height: 4.5rem;
  field-sizing: content;
}

.crm-quote-item-row__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.6rem;
  margin-top: 0.5rem;
}

.crm-quote-item-row__field--desc {
  grid-column: 1 / -1;
}

.crm-quote-item-row__totals {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  padding: 0.3rem 0 0;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.crm-quote-item-row__total-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  color: var(--crm-text-secondary);
}

.crm-quote-item-row__total-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--crm-text-muted);
}

.crm-quote-item-row__total-value {
  font-weight: 600;
  color: var(--crm-text);
}

.crm-quote-item-row__total-chip--primary .crm-quote-item-row__total-label,
.crm-quote-item-row__total-chip--primary .crm-quote-item-row__total-value {
  color: var(--crm-accent);
  font-weight: 700;
}

.crm-quote-item-row__obs {
  margin-top: 0.35rem;
}

.quote-item-row .position-relative {
  z-index: 15;
}

.quote-item-row .crm-search-results {
  z-index: 1085;
}

/* ── Móvil: la lista de Artículos NO debe ser un scroll container anidado.
   En WebView móvil (Turbo Native) y navegadores táctiles, un div con
   overflow:auto + overscroll-behavior:contain captura los touch events de
   scroll y congela el scroll de la página, incluso cuando el contenido cabe.
   En móvil la lista crece con su contenido y la página hace scroll como una
   unidad. El scroll interno con max-height se reserva para desktop (≥ 768px). */
@media (max-width: 767.98px) {
  .crm-quote-items-panel__list {
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
  }
}

@media (min-width: 768px) {
  .crm-quote-items-panel__list {
    max-height: min(36rem, 60vh);
  }

  /* 12 columnas / 2 filas: identidad arriba, métricas abajo; totales a la derecha */
  .crm-quote-item-row__grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 0.55rem 0.75rem;
    align-items: end;
    min-width: 42rem;
  }

  .crm-quote-item-row__field--key {
    grid-column: 1 / 3;
    grid-row: 1;
  }

  .crm-quote-item-row__field--unit {
    grid-column: 3 / 5;
    grid-row: 1;
  }

  .crm-quote-item-row__field--desc {
    grid-column: 5 / 11;
    grid-row: 1;
  }

  .crm-quote-item-row__field--qty {
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .crm-quote-item-row__field--price {
    grid-column: 3 / 7;
    grid-row: 2;
  }

  .crm-quote-item-row__field--discount {
    grid-column: 7 / 9;
    grid-row: 2;
  }

  .crm-quote-item-row__field--tax {
    grid-column: 9 / 11;
    grid-row: 2;
  }

  .crm-quote-item-row__totals {
    grid-column: 11 / 13;
    grid-row: 1 / 3;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0 0 0.15rem;
    justify-content: flex-end;
    align-self: stretch;
  }

  .crm-quote-item-row__total-chip {
    justify-content: space-between;
    gap: 0.55rem;
    min-width: 0;
    width: 100%;
  }
}

.sales-cycle-contact-display {
  margin-top: 0.5rem;
}

.sales-cycle-new-contact {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--crm-radius-xs);
  border: 1px dashed color-mix(in srgb, var(--crm-accent) 35%, var(--crm-border));
  background: var(--crm-accent-light);
}

.sales-cycle-new-contact__title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--crm-text);
}

.sales-cycle-new-contact__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sales-cycle-delivery-destinations__list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sales-cycle-delivery-destination {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background: var(--crm-surface);
  cursor: pointer;
}

.sales-cycle-delivery-destination:has(input:checked) {
  border-color: color-mix(in srgb, var(--crm-accent) 55%, var(--crm-border));
  background: var(--crm-accent-light);
}

.sales-cycle-delivery-destination .form-check-input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.sales-cycle-delivery-destination__content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.sales-cycle-delivery-destination__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--crm-text);
}

.sales-cycle-delivery-destination__subtitle {
  font-size: 0.78rem;
  color: var(--crm-text-muted);
}

.sales-cycle-delivery-destination__meta {
  font-size: 0.78rem;
  color: var(--crm-text-muted);
  line-height: 1.35;
}

.sales-cycle-delivery-destination__images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.sales-cycle-delivery-destination__image-link {
  display: block;
  line-height: 0;
  border-radius: var(--crm-radius-xs);
  overflow: hidden;
  border: 1px solid var(--crm-border);
}

.sales-cycle-delivery-destination__thumb {
  width: 2.75rem;
  height: 2.75rem;
  object-fit: cover;
  display: block;
}

.sales-cycle-delivery-destinations__hint {
  font-size: 0.82rem;
}

.sc-detail-footer {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 2;
  border-top: 1px solid var(--crm-border);
  background: var(--crm-surface);
  padding: 0.65rem 1rem;
  padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  box-shadow: 0 -4px 24px rgba(26, 29, 35, 0.08);
}

[data-bs-theme="dark"] .sc-detail-footer {
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
}

.sc-detail-footer__inner {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.sales-cycle-btn-action {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.25rem;
  font-weight: 600;
  border-radius: var(--crm-radius-xs);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sales-cycle-btn-submit {
  flex: 1 1 auto;
  font-size: 1rem;
}

/* Oculta Guardar en pestañas sin formulario, sin romper el responsive (d-*) */
.sc-tab-save-hidden {
  display: none !important;
}

.sales-cycle-btn-cancel {
  flex: 0 0 auto;
}

/* PDF preview overlay (facturas / pedidos) */
.sc-pdf-preview {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-top: calc(1rem + env(safe-area-inset-top, 0px));
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

.sc-pdf-preview[hidden] {
  display: none !important;
}

.sc-pdf-preview__backdrop {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: rgba(15, 23, 42, 0.55);
  cursor: pointer;
  z-index: 0;
}

.sc-pdf-preview__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1100px, 100%);
  max-height: calc(100dvh - 2rem);
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  box-shadow: var(--crm-shadow-lg);
  overflow: hidden;
  pointer-events: auto;
}

.sc-pdf-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--crm-border);
  background: var(--crm-surface);
}

.sc-pdf-preview__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--crm-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-pdf-preview__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1rem 1.25rem 1.25rem;
}

.sc-pdf-preview__frame {
  display: block;
  width: 100%;
  height: min(75dvh, calc(100dvh - 8rem));
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-bg);
}

body.sc-pdf-preview-open {
  overflow: hidden;
}

.sales-cycles-page,
.repair-cycles-page {
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 992px) {
  .admin-main:has(.sales-cycles-shell),
  .admin-main:has(.repair-cycles-shell) {
    min-height: 100dvh;
  }
}

@media (max-width: 575.98px) {
  .sc-detail-back__label {
    display: none;
  }

  .sc-detail-back {
    padding: 0.4rem 0.65rem;
  }

  .sc-detail-header {
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    padding-left: calc(0.75rem + env(safe-area-inset-left, 0px));
    padding-right: calc(0.75rem + env(safe-area-inset-right, 0px));
  }

  .sc-detail-title {
    font-size: 0.95rem;
  }

  /* Header en una fila: título con ellipsis + badges fijos (ahorra ~1 fila) */
  .sc-detail-header__main {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 0.5rem;
  }

  .sc-detail-header__main .sc-detail-title {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
  }

  .sc-detail-header__main .sc-detail-stage-badge,
  .sc-detail-header__main .sc-detail-case-id {
    flex-shrink: 0;
  }

  /* Más ancho útil para los campos en teléfono */
  .sc-detail-body {
    padding: 0.75rem;
    padding-left: calc(0.75rem + env(safe-area-inset-left, 0px));
    padding-right: calc(0.75rem + env(safe-area-inset-right, 0px));
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }

  /* Botones de pulgar a 48px en teléfono */
  .sc-detail-footer .sales-cycle-btn-action {
    min-height: 3rem;
  }
}

@media (max-width: 380px) {
  .sc-detail-footer .sales-cycle-btn-action {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }
}

@media (max-width: 991.98px) {
  /* Modal a pantalla completa: sin gutter del contenido ni cromo de tarjeta.
     El !important vence a .p-3/.p-lg-4 de Bootstrap (ambos !important). */
  .admin-content:has(.sc-detail-view.is-open) {
    padding: 0 !important;
  }

  .sc-detail-view {
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  /* Pista visual de scroll horizontal en las pestañas (igual que el kanban) */
  .sc-detail-tabs-wrap {
    mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.25rem), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.25rem), transparent 100%);
  }

  /* Toolbar Trix táctil: ver sección "Trix móvil — sales_cycles" al final. */
}

@media (min-width: 768px) {
  .sales-cycles-page,
  .repair-cycles-page {
    padding-bottom: 0;
  }

  .sc-detail-header {
    padding: 0.75rem 1.5rem;
    padding-left: calc(1.5rem + env(safe-area-inset-left, 0px));
    padding-right: calc(1.5rem + env(safe-area-inset-right, 0px));
  }

  .sc-detail-title {
    font-size: 1.25rem;
  }

  .sc-detail-tabs-wrap {
    padding: 0.6rem 1.5rem;
    padding-left: calc(1.5rem + env(safe-area-inset-left, 0px));
    padding-right: calc(1.5rem + env(safe-area-inset-right, 0px));
  }

  .sc-detail-body {
    padding: 1.25rem 1.5rem;
    padding-left: calc(1.5rem + env(safe-area-inset-left, 0px));
    padding-right: calc(1.5rem + env(safe-area-inset-right, 0px));
    /* Footer in-flow: sin despeje extra (igual que desktop) */
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }

  .sc-detail-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  /* Barra de comandos alineada a la derecha en tablet */
  .sc-detail-footer__inner {
    justify-content: flex-end;
  }

  .sales-cycle-form-section {
    margin-bottom: 0;
  }

  .sales-cycle-form-section__body {
    padding: 1.15rem 1.25rem;
  }

  .sales-cycle-btn-submit {
    flex: 0 0 auto;
    min-width: 8rem;
  }
}

@media (min-width: 992px) {
  /* Desktop: se guarda desde el header; el footer sticky desaparece */
  .sc-detail-footer {
    display: none;
  }

  .sc-detail-body {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }
}

/* Landscape bajo: compactar paddings sin reducir targets táctiles */
@media (max-height: 500px) {
  .sc-detail-header {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
  }

  .sc-detail-tabs-wrap {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  .sc-detail-body {
    padding-top: 0.75rem;
  }

  .sc-detail-view .sales-cycle-form-section__title {
    padding: 0.6rem 0.875rem;
  }

  .sc-detail-view .sales-cycle-form-section__body {
    padding: 0.875rem;
  }
}

/* ═══════════════════════════════════════════
   Sales Cycles — filtro por usuario
   ═══════════════════════════════════════════ */
.sc-filters {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.sc-filters .crm-filter-bar__label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
  margin-bottom: 0.25rem;
}

.sc-filters .form-select {
  min-height: 2.75rem;
  font-size: 0.9375rem;
}

@media (min-width: 768px) {
  .sc-filters {
    padding: 1rem 1.15rem;
  }

  .sc-filters .crm-filter-bar {
    grid-template-columns: 1fr auto;
    align-items: end;
  }
}

@media (max-width: 767.98px) {
  .sc-filters {
    border-radius: var(--crm-radius-xs);
    padding: 0.65rem;
  }

  .sc-filters .crm-filter-bar {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .sc-filters .form-select {
    min-height: 2.5rem;
    font-size: 0.875rem;
  }
}

/* ═══════════════════════════════════════════
   Sales Cycles — view toggle + calendar
   ═══════════════════════════════════════════ */
.sc-view-toggle {
  display: inline-flex;
  flex: 1 1 auto;
  padding: 0.2rem;
  gap: 0.15rem;
  background: color-mix(in srgb, var(--crm-surface) 80%, var(--crm-bg));
  border: 1px solid var(--crm-border);
  border-radius: 999px;
  min-height: 2.75rem;
}
.sc-view-toggle__btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.35rem;
  padding: 0 0.85rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--crm-text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.sc-view-toggle__btn.active {
  background: var(--crm-surface);
  color: var(--crm-accent);
  box-shadow: var(--crm-shadow);
}
.sc-view-toggle__btn:focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: 2px;
}

.sc-calendar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}
.sc-calendar-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.75rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  box-shadow: var(--crm-shadow);
  position: sticky;
  top: 60px;
  z-index: 20;
}
.sc-calendar-toolbar__modes {
  display: flex;
  padding: 0.2rem;
  gap: 0.15rem;
  background: color-mix(in srgb, var(--crm-bg) 70%, var(--crm-surface));
  border-radius: 999px;
}
.sc-calendar-mode-btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.5rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--crm-text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sc-calendar-mode-btn.active {
  background: var(--crm-surface);
  color: var(--crm-accent);
  box-shadow: var(--crm-shadow);
}
.sc-calendar-toolbar__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
.sc-calendar-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0 0.65rem;
  border: 1px solid var(--crm-border);
  border-radius: 999px;
  background: var(--crm-surface);
  color: var(--crm-text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sc-calendar-nav-btn--today {
  flex: 1 1 auto;
  max-width: 8rem;
  color: var(--crm-accent);
  border-color: color-mix(in srgb, var(--crm-accent) 35%, var(--crm-border));
  background: var(--crm-accent-light);
}
.sc-calendar-nav-btn:active {
  transform: scale(0.97);
}
.sc-calendar-toolbar__label {
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--crm-text);
  letter-spacing: -0.02em;
}

.sc-calendar-body {
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

/* Week — mobile agenda */
.sc-calendar-week-agenda {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.sc-calendar-week-grid {
  display: none;
}
.sc-calendar-agenda-day {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  overflow: hidden;
  box-shadow: var(--crm-shadow);
}
.sc-calendar-agenda-day--today {
  border-color: color-mix(in srgb, var(--crm-accent) 45%, var(--crm-border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--crm-accent) 20%, transparent);
}
.sc-calendar-agenda-day__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: color-mix(in srgb, var(--crm-bg) 50%, var(--crm-surface));
  border-bottom: 1px solid var(--crm-border-light);
}
.sc-calendar-agenda-day--today .sc-calendar-agenda-day__header {
  background: var(--crm-accent-light);
}
.sc-calendar-agenda-day__weekday {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
}
.sc-calendar-agenda-day__date {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--crm-text);
  line-height: 1;
}
.sc-calendar-agenda-day__count {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
}
.sc-calendar-agenda-day__events {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.65rem;
}
.sc-calendar-empty-day {
  margin: 0;
  padding: 0.35rem 0.15rem;
  font-size: 0.82rem;
  color: var(--crm-text-muted);
}

/* Events */
.sc-calendar-event {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--sc-event-color, var(--crm-accent)) 35%, var(--crm-border));
  border-left: 3px solid var(--sc-event-color, var(--crm-accent));
  border-radius: 8px;
  background: color-mix(in srgb, var(--sc-event-color, var(--crm-accent)) 8%, var(--crm-surface));
  color: var(--crm-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.sc-calendar-event:active {
  transform: scale(0.99);
}
.sc-calendar-event--chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.45rem;
  font-size: 0.75rem;
  min-height: 2rem;
}
.sc-calendar-event__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--sc-event-color, var(--crm-accent));
  flex-shrink: 0;
}
.sc-calendar-event--card,
.sc-calendar-event--card-full {
  padding: 0.65rem 0.75rem;
  min-height: 2.75rem;
}
.sc-calendar-event__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.sc-calendar-event__stage {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--sc-event-color, var(--crm-accent));
}
.sc-calendar-event__priority {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--sc-priority-color, #94a3b8) 12%, transparent);
  color: var(--sc-priority-color, var(--crm-text-secondary));
}
.sc-calendar-event__priority.priority-high {
  --sc-priority-color: #e63946;
}
.sc-calendar-event__priority.priority-medium {
  --sc-priority-color: #d97706;
}
.sc-calendar-event__priority.priority-low {
  --sc-priority-color: #94a3b8;
}
.sc-calendar-event__priority-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--sc-priority-color, #94a3b8);
  flex-shrink: 0;
}
.sc-calendar-event__dots {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.sc-calendar-event__title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--crm-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sc-calendar-event--card-full .sc-calendar-event__title {
  white-space: normal;
}
.sc-calendar-event__meta {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--crm-text-secondary);
  line-height: 1.35;
}
.sc-calendar-more {
  display: block;
  width: 100%;
  margin-top: 0.15rem;
  padding: 0.2rem 0.35rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--crm-accent);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

/* Month view */
.sc-calendar-month {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  box-shadow: var(--crm-shadow);
  overflow: hidden;
}
.sc-calendar-month__header,
.sc-calendar-month__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.sc-calendar-month__header {
  border-bottom: 1px solid var(--crm-border-light);
  background: color-mix(in srgb, var(--crm-bg) 55%, var(--crm-surface));
}
.sc-calendar-month-head {
  padding: 0.45rem 0.15rem;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--crm-text-muted);
}
.sc-calendar-month-cell {
  min-height: 4.5rem;
  padding: 0.25rem 0.2rem;
  border-right: 1px solid var(--crm-border-light);
  border-bottom: 1px solid var(--crm-border-light);
  cursor: default;
}
.sc-calendar-month-cell:nth-child(7n) {
  border-right: none;
}
.sc-calendar-month-cell--outside {
  opacity: 0.45;
}
.sc-calendar-month-cell--today {
  background: color-mix(in srgb, var(--crm-accent) 10%, var(--crm-surface));
}
.sc-calendar-month-cell--today .sc-calendar-month-cell__num {
  background: var(--crm-accent);
  color: #fff;
}
.sc-calendar-month-cell__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-bottom: 0.15rem;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--crm-text);
}
.sc-calendar-month-cell__events {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sc-calendar-day-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  max-height: min(70dvh, 520px);
  display: flex;
  flex-direction: column;
  background: var(--crm-surface);
  border-top: 1px solid var(--crm-border);
  border-radius: 1rem 1rem 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sc-calendar-day-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--crm-border-light);
}
.sc-calendar-day-panel__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--crm-text);
  text-transform: capitalize;
}
.sc-calendar-day-panel__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--crm-bg) 60%, var(--crm-surface));
  color: var(--crm-text-secondary);
  cursor: pointer;
}
.sc-calendar-day-panel__events {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
  .crm-page-header__actions .sc-view-toggle {
    flex: 0 0 auto;
    min-width: 11rem;
  }

  .sc-calendar-toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
  }
  .sc-calendar-toolbar__modes {
    flex: 0 0 auto;
    min-width: 14rem;
  }
  .sc-calendar-toolbar__nav {
    flex: 0 0 auto;
  }
  .sc-calendar-toolbar__label {
    flex: 1 1 auto;
    text-align: center;
    order: 3;
    width: 100%;
  }

  .sc-calendar-week-agenda {
    display: none;
  }
  .sc-calendar-week-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
    min-height: 50vh;
  }
  .sc-calendar-week-col {
    display: flex;
    flex-direction: column;
    min-height: 12rem;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-sm);
    overflow: hidden;
    box-shadow: var(--crm-shadow);
  }
  .sc-calendar-week-col--today {
    border-color: color-mix(in srgb, var(--crm-accent) 45%, var(--crm-border));
  }
  .sc-calendar-week-col__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.55rem 0.35rem;
    border-bottom: 1px solid var(--crm-border-light);
    background: color-mix(in srgb, var(--crm-bg) 50%, var(--crm-surface));
  }
  .sc-calendar-week-col--today .sc-calendar-week-col__header {
    background: var(--crm-accent-light);
  }
  .sc-calendar-week-col__weekday {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--crm-text-muted);
  }
  .sc-calendar-week-col__date {
    font-size: 1rem;
    font-weight: 800;
    color: var(--crm-text);
  }
  .sc-calendar-week-col__events {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.45rem;
    flex: 1 1 auto;
  }

  .sc-calendar-month-cell {
    min-height: 6.5rem;
    padding: 0.35rem;
  }
  .sc-calendar-month-cell[data-day-key] {
    cursor: pointer;
  }
  .sc-calendar-month-cell[data-day-key]:hover {
    background: color-mix(in srgb, var(--crm-accent) 6%, var(--crm-surface));
  }

  .sc-calendar-day-panel {
    position: static;
    max-height: none;
    border-radius: var(--crm-radius-sm);
    box-shadow: var(--crm-shadow);
    margin-top: 0.5rem;
  }
}

@supports (-webkit-touch-callout: none) {
  .sc-detail-footer {
    backdrop-filter: blur(12px);
    background-color: color-mix(in srgb, var(--crm-surface) 92%, transparent);
  }

  .sc-detail-tabs .nav-link,
  .sc-detail-back,
  .sales-cycle-btn-action {
    -webkit-tap-highlight-color: transparent;
  }
}


/* ── Reporte de recepción ──────────────── */
.rc-reception-report {
  padding: 0;
}

.rc-reception-report__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rc-reception-report__actions .btn {
  flex: 1 1 auto;
}

.rc-reception-report__divider {
  border-color: var(--crm-border);
  margin: 1rem 0;
}

.rc-reception-report__email-form .input-group {
  gap: 0;
}

.rc-reception-report__email-form input[type="email"] {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.rc-reception-report__email-form button[type="submit"] {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.rc-reception-report__preview {
  margin-bottom: 1.25rem;
}

.rc-reception-report__preview-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
  margin: 0 0 0.45rem;
}

.rc-reception-report__gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.rc-reception-report__thumb {
  display: block;
  width: 5.5rem;
  height: 5.5rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-surface-alt);
  overflow: hidden;
}

.rc-reception-report__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rc-reception-report__signature {
  max-width: 22rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: #ffffff;
}

.rc-reception-report__signature img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 7rem;
  object-fit: contain;
}

/* ── Tab Formulario de recepción ─────────── */
.rc-reception-form {
  padding: 0;
}

.rc-reception-form__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.rc-reception-form__badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--crm-accent);
  background: var(--crm-accent-light);
  border: 1px solid color-mix(in srgb, var(--crm-accent) 22%, transparent);
  border-radius: var(--crm-radius-xs);
}

.rc-reception-form__hint {
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--crm-text-secondary);
  background: var(--crm-surface-alt);
  border: 1px solid var(--crm-border-light);
  border-radius: var(--crm-radius-xs);
}

.rc-reception-form__hint--readonly {
  color: var(--crm-text-muted);
}

.rc-reception-form .rc-service-form-fields {
  width: 100%;
  max-width: 100%;
  padding-left: 0;
  padding-right: 0;
}

.rc-reception-form .rc-service-form-fields__item:last-child {
  margin-bottom: 0;
}

.rc-reception-form .form-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  margin: 0;
  padding: 0.4rem 0.75rem 0.4rem 2rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background: var(--crm-surface-alt);
}

.rc-reception-form .form-check-input {
  margin-top: 0;
}

.rc-reception-form .form-check-input:checked {
  background-color: var(--crm-accent);
  border-color: var(--crm-accent);
}

.rc-reception-form .form-check-label {
  color: var(--crm-text);
  font-size: 0.9rem;
}

.rc-reception-form__answers {
  display: flex;
  flex-direction: column;
}

.rc-reception-form__answers .sales-cycle-kv__label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.75rem;
  font-weight: 600;
}

.rc-reception-form__file-block {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--crm-border-light);
}

.rc-reception-form__file-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.rc-service-form-fields__thumb {
  display: block;
  width: 5rem;
  height: 5rem;
  object-fit: cover;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface-alt);
}

@media (max-width: 767.98px) {
  .rc-reception-form__answers .sales-cycle-kv {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }

  .rc-reception-form__answers .sales-cycle-kv__value {
    text-align: left;
  }
}

/* Custom scrollbar */
.admin-body ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.admin-body ::-webkit-scrollbar-thumb {
  background: var(--crm-scroll-thumb);
  border-radius: 3px;
}
.admin-body ::-webkit-scrollbar-track {
  background: var(--crm-scroll-track);
}

/* ── Loading spinner overlay ──────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--crm-spinner-bg);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
  will-change: opacity, visibility;
}
.loading-overlay.loading-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.loading-overlay .spinner-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--crm-border);
  border-top-color: var(--crm-accent);
  border-radius: 50%;
  animation: crm-spin 0.75s linear infinite;
}
@keyframes crm-spin {
  to { transform: rotate(360deg); }
}

/* ── Inventory import progress overlay ───── */
.import-progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background-color: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  pointer-events: none;
}

.import-progress-overlay--visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.import-progress-panel {
  width: min(100%, 420px);
  padding: 2rem 1.75rem;
  background: var(--crm-topbar-bg, #fff);
  animation: import-panel-enter 0.35s ease;
}

@keyframes import-panel-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.import-progress-panel__icon {
  width: 64px;
  height: 64px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background: rgba(79, 70, 229, 0.12);
  color: var(--crm-accent, #4f46e5);
  font-size: 1.75rem;
  animation: import-icon-pulse 1.6s ease-in-out infinite;
}

@keyframes import-icon-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}

.import-progress-track {
  height: 10px;
  background: var(--crm-border, #e2e8f0);
  overflow: hidden;
}

@media (max-width: 767.98px) {
  .import-progress-track {
    height: 8px;
  }
}

.import-progress-bar {
  height: 100%;
  background: var(--crm-accent);
  background-image: none;
  transition: width 0.35s ease;
  position: relative;
  overflow: hidden;
}

.import-progress-bar::after {
  content: none;
  display: none;
}

@keyframes import-bar-shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.import-progress-percent {
  font-size: 1.25rem;
  color: var(--crm-accent, #4f46e5);
}

.import-progress-eta {
  font-size: 0.85rem;
  text-align: right;
}

.import-card {
  position: relative;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.import-card--active,
.import-card--busy {
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.18), var(--crm-shadow, 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075));
}

.import-card--active::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.12);
  animation: import-card-glow 2s ease-in-out infinite;
}

@keyframes import-card-glow {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.import-card-indicator {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: min(100%, 220px);
  padding: 0.875rem 1rem;
  border-radius: 1rem;
  background: rgba(79, 70, 229, 0.08);
  border: 1px solid rgba(79, 70, 229, 0.16);
  animation: import-indicator-enter 0.35s ease;
}

@keyframes import-indicator-enter {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.import-card-indicator__pulse {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  margin-top: 0.35rem;
  border-radius: 50%;
  background: var(--crm-accent, #4f46e5);
  box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.45);
  animation: import-card-pulse 1.5s ease-out infinite;
}

@keyframes import-card-pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.45);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(79, 70, 229, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
  }
}

.import-card-indicator__content {
  flex: 1;
  min-width: 0;
}

.import-card-indicator__label {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--crm-accent, #4f46e5);
  margin-right: 0.5rem;
}

.import-card-indicator__percent {
  font-size: 0.95rem;
  color: var(--crm-accent, #4f46e5);
}

.import-card-indicator__message {
  font-size: 0.82rem;
  color: var(--crm-text-secondary, #64748b);
}

.import-card-indicator__bar {
  min-width: 0;
}

/* ── Mobile top navbar — command bar ─────── */
.admin-mobile-nav {
  min-height: var(--crm-topbar-height, 48px);
  height: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px));
  z-index: 1040;
  background-color: var(--crm-topbar-bg);
  border-bottom: 1px solid var(--crm-border);
  box-shadow: none;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.admin-mobile-nav .navbar-brand {
  color: var(--crm-text);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0;
}
.admin-mobile-nav .btn {
  color: var(--crm-text-secondary);
  min-width: 2.75rem;
  min-height: 2.75rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.admin-mobile-nav .btn:hover {
  color: var(--crm-text);
  background-color: var(--crm-hover);
}

/* ── Wrapper ──────────────────────────────── */
.admin-wrapper {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px));
}

/* ── Sidebar — Dynamics nav rail ─────────── */
.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--crm-sidebar-width);
  height: 100vh;
  z-index: 1050;
  transition: width 0.2s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: var(--crm-sidebar-bg);
  border-right: 1px solid var(--crm-sidebar-border);
  box-shadow: none;
}

.admin-sidebar hr {
  border-color: var(--crm-sidebar-border);
  opacity: 1;
}

.admin-sidebar .sidebar-nav {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

/* Sidebar brand */
.admin-sidebar .sidebar-brand-text {
  color: var(--crm-sidebar-text);
  font-weight: 600;
  letter-spacing: 0;
  font-size: 1rem;
}

/* Sidebar navigation links — Fluent density */
.admin-sidebar .nav-link {
  position: relative;
  padding: 0.55rem 0.85rem;
  margin: 0.1rem 0.5rem;
  transition: background-color 0.12s ease, color 0.12s ease;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--crm-sidebar-text);
  border-radius: var(--crm-radius-sm);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.admin-sidebar .nav-link i {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1rem;
  color: var(--crm-sidebar-text-muted);
  transition: color 0.12s ease;
}
.admin-sidebar .nav-link:hover {
  background-color: var(--crm-sidebar-hover);
  color: var(--crm-sidebar-text);
}
.admin-sidebar .nav-link:hover i {
  color: var(--crm-sidebar-text);
}
.admin-sidebar .nav-link.active {
  background-color: var(--crm-sidebar-active-bg);
  color: var(--crm-sidebar-active-text);
  font-weight: 600;
}
.admin-sidebar .nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--crm-sidebar-accent);
}
.admin-sidebar .nav-link.active i {
  color: var(--crm-sidebar-active-text);
}

/* Submenu — nested rail + denser single-line items */
.submenu {
  max-height: 0;
  overflow: hidden;
  margin: 0 0.5rem 0 1.15rem;
  padding: 0 0 0 0.55rem;
  border-left: 2px solid transparent;
  border-radius: 0 var(--crm-radius-xs) var(--crm-radius-xs) 0;
  background: transparent;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s ease,
              padding 0.25s ease,
              margin 0.25s ease,
              border-color 0.25s ease,
              background-color 0.25s ease;
  opacity: 0;
}
.submenu.open {
  /* Altura dinámica: el JS ajusta al espacio real bajo el botón en < FHD. */
  max-height: min(40rem, var(--submenu-expanded-max-height, calc(100vh - 8rem)));
  overflow-y: auto;
  opacity: 1;
  margin: 0.15rem 0.5rem 0.35rem 1.15rem;
  padding: 0.25rem 0 0.3rem 0.55rem;
  border-left-color: var(--crm-sidebar-border);
  background: rgba(0, 0, 0, 0.12);
}
.submenu .nav-link {
  margin-left: 0;
  margin-right: 0;
  padding: 0.45rem 0.65rem;
  min-height: 2.25rem;
  font-size: 0.8125rem;
  font-weight: 400;
  gap: 0.55rem;
  line-height: 1.25;
}
.submenu .nav-link > span {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.submenu .nav-link i {
  flex: 0 0 auto;
  width: 1.05rem;
  height: 1.05rem;
  font-size: 0.8rem;
}
.submenu .nav-link.active::before {
  display: none;
}
.submenu-section {
  margin: 0.45rem 0 0.15rem;
  padding: 0 0.65rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--crm-sidebar-text-muted);
  line-height: 1.2;
  user-select: none;
}
.submenu-section:first-child {
  margin-top: 0.15rem;
}
.submenu-toggle .fa-chevron-down {
  transition: transform 0.3s ease;
  color: var(--crm-sidebar-text-muted);
  font-size: 0.65rem;
}
.submenu-toggle.rotate-180 .fa-chevron-down {
  transform: rotate(180deg);
}

/* Sidebar collapse button */
.sidebar-collapse-btn {
  background: transparent;
  border: none;
  color: var(--crm-sidebar-text-muted);
  padding: 0.35rem 0.6rem;
  border-radius: var(--crm-radius-xs);
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}
.sidebar-collapse-btn i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  transition: transform 0.2s ease;
}
.sidebar-collapse-btn:hover {
  color: var(--crm-sidebar-text);
  background-color: var(--crm-sidebar-hover);
}

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--crm-sidebar-border);
}

/* ── Overlay ──────────────────────────────── */
.admin-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(3px);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.admin-sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* ── Main content ─────────────────────────── */
.admin-main {
  width: 100%;
  min-height: calc(100vh - var(--crm-topbar-height, 48px));
  min-height: calc(100dvh - var(--crm-topbar-height, 48px));
  background-color: var(--crm-bg);
}
.admin-content {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
}

/* ── Topbar — Dynamics command bar ───────── */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background-color: var(--crm-topbar-bg);
  border-bottom: 1px solid var(--crm-border);
  height: var(--crm-topbar-height, 48px);
  box-shadow: none;
}

/* ── Notifications dropdown (movimientos) ── */
.crm-notifications {
  position: relative;
}

.crm-notifications__menu {
  width: min(400px, calc(100vw - 1.5rem));
  padding: 0;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  background-color: var(--crm-surface);
  overflow: hidden;
  margin-top: 0.35rem !important;
  box-shadow: var(--crm-shadow-lg);
}

.crm-notifications__header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--crm-border-light);
  background-color: var(--crm-surface-alt, var(--crm-bg));
  position: sticky;
  top: 0;
  z-index: 2;
}

.crm-notifications__titles {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.crm-notifications__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--crm-text);
  white-space: nowrap;
}

.crm-notifications__pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.crm-notifications__pill--unread {
  background-color: color-mix(in srgb, var(--crm-accent, #1e3a5f) 12%, transparent);
  border-color: color-mix(in srgb, var(--crm-accent, #1e3a5f) 32%, transparent);
  color: var(--crm-accent, #1e3a5f);
}

.crm-notifications__pill--muted {
  background-color: var(--crm-bg);
  border-color: var(--crm-border-light);
  color: var(--crm-text-secondary);
}

.crm-notifications__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.crm-notifications__action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--crm-text-secondary);
  background-color: transparent;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  padding: 0.45rem 0.7rem;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}

.crm-notifications__action:hover {
  color: var(--crm-accent);
  border-color: color-mix(in srgb, var(--crm-accent, #1e3a5f) 45%, transparent);
  background-color: color-mix(in srgb, var(--crm-accent, #1e3a5f) 7%, transparent);
}

.crm-notifications__action:focus-visible,
.crm-notifications__close:focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: 2px;
}

.crm-notifications__action:disabled,
.crm-notifications__action.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.crm-notifications__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background-color: transparent;
  color: var(--crm-text-secondary);
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
}

.crm-notifications__close:hover {
  color: var(--crm-text);
  background-color: var(--crm-hover);
}

.crm-notifications__list {
  max-height: min(480px, 65vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--crm-border) transparent;
}

.crm-notifications__list::-webkit-scrollbar {
  width: 6px;
}

.crm-notifications__list::-webkit-scrollbar-thumb {
  background-color: var(--crm-border);
  border-radius: 999px;
}

.crm-notifications__item {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  padding: 0.875rem 1rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--crm-border-light);
  transition: background-color 0.12s ease;
  touch-action: manipulation;
}

.crm-notifications__item:last-child {
  border-bottom: 0;
}

.crm-notifications__item:hover {
  background-color: var(--crm-hover, rgba(0, 0, 0, 0.04));
  color: inherit;
}

.crm-notifications__item:focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: -2px;
  color: inherit;
}

.crm-notifications__item--unread {
  background-color: color-mix(in srgb, var(--crm-accent, #1e3a5f) 7%, transparent);
}

.crm-notifications__item--unread:hover {
  background-color: color-mix(in srgb, var(--crm-accent, #1e3a5f) 11%, transparent);
}

.crm-notifications__item--unread .crm-notifications__item-title {
  font-weight: 600;
  color: var(--crm-text);
}

.crm-notifications__item--read .crm-notifications__item-title {
  font-weight: 500;
  color: var(--crm-text-secondary);
}

.crm-notifications__item--read .crm-notifications__item-text,
.crm-notifications__item--read .crm-notifications__meta {
  color: var(--crm-text-muted);
}

.crm-notifications__icon {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--crm-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--crm-bg);
  color: var(--crm-accent, #1e3a5f);
  font-size: 0.95rem;
}

.crm-notifications__icon--success {
  background-color: color-mix(in srgb, var(--crm-success, #15803d) 12%, transparent);
  color: var(--crm-success, #15803d);
}

.crm-notifications__icon--info {
  background-color: color-mix(in srgb, var(--crm-info, #0e6e8a) 12%, transparent);
  color: var(--crm-info, #0e6e8a);
}

.crm-notifications__icon--warning {
  background-color: color-mix(in srgb, var(--crm-warning, #b45309) 13%, transparent);
  color: var(--crm-warning, #b45309);
}

.crm-notifications__icon--danger {
  background-color: color-mix(in srgb, var(--crm-danger, #b91c1c) 11%, transparent);
  color: var(--crm-danger, #b91c1c);
}

.crm-notifications__body {
  min-width: 0;
  flex: 1 1 auto;
}

.crm-notifications__item-title {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--crm-text);
  line-height: 1.4;
}

.crm-notifications__item-title-text {
  min-width: 0;
}

.crm-notifications__dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 0.35rem;
  border-radius: 50%;
  background-color: var(--crm-accent, #1e3a5f);
}

.crm-notifications__item-text {
  font-size: 0.8125rem;
  color: var(--crm-text-secondary);
  line-height: 1.5;
  margin-top: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.crm-notifications__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

.crm-notifications__time {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.crm-notifications__chevron {
  flex: 0 0 auto;
  align-self: center;
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--crm-text-muted);
}

.crm-notifications__item:hover .crm-notifications__chevron {
  color: var(--crm-accent);
}

.crm-notifications__empty {
  padding: 2rem 1.5rem;
  text-align: center;
}

.crm-notifications__empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.75rem;
  border-radius: 50%;
  background-color: color-mix(in srgb, var(--crm-accent, #1e3a5f) 10%, transparent);
  color: var(--crm-accent, #1e3a5f);
  font-size: 1.1rem;
}

.crm-notifications__empty-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--crm-text);
}

.crm-notifications__empty-text {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--crm-text-muted);
  max-width: 30ch;
  margin-left: auto;
  margin-right: auto;
}

.crm-notifications__badge {
  min-width: 1.1rem;
  line-height: 1.2;
}

[data-bs-theme="dark"] .crm-notifications__item:hover,
[data-bs-theme="dark"] .crm-notifications__item:focus-visible {
  background-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .crm-notifications__item--unread {
  background-color: color-mix(in srgb, var(--crm-accent, #5b8ab5) 14%, transparent);
}

[data-bs-theme="dark"] .crm-notifications__item--unread:hover {
  background-color: color-mix(in srgb, var(--crm-accent, #5b8ab5) 20%, transparent);
}

[data-bs-theme="dark"] .crm-notifications__item--unread .crm-notifications__item-title {
  color: var(--crm-text);
}

[data-bs-theme="dark"] .crm-notifications__dot {
  background-color: var(--crm-accent, #5b8ab5);
}

/* ── Notifications: panel tipo hoja en móvil (< 992px) ── */
@media (max-width: 991.98px) {
  .admin-mobile-nav .crm-notifications__menu,
  .admin-mobile-nav .crm-notifications__menu[data-bs-popper] {
    position: fixed !important;
    top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px) + 0.5rem) !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    width: auto;
    margin-top: 0 !important;
    transform: none !important;
    z-index: 1050;
    display: none;
    flex-direction: column;
    max-height: calc(70dvh + env(safe-area-inset-bottom, 0px));
  }

  .admin-mobile-nav .crm-notifications__menu.show {
    display: flex;
  }

  .admin-mobile-nav .crm-notifications__header {
    flex: 0 0 auto;
    padding: 0.75rem 0.875rem;
  }

  .admin-mobile-nav .crm-notifications__list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  .admin-mobile-nav .crm-notifications__item {
    padding: 1rem 0.875rem;
    gap: 0.875rem;
  }

  .admin-mobile-nav .crm-notifications__item-title {
    font-size: 0.9375rem;
  }

  .admin-mobile-nav .crm-notifications__item-text {
    font-size: 0.875rem;
  }

  .admin-mobile-nav .crm-notifications__action {
    min-height: 44px;
    font-size: 0.8125rem;
  }

  .admin-mobile-nav .crm-notifications__empty {
    padding: 2.5rem 1.5rem calc(2rem + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Cards — Fluent surface (borde > sombra) ─ */
.card {
  border: 1px solid var(--crm-border) !important;
  border-radius: var(--crm-radius) !important;
  background-color: var(--crm-surface);
  box-shadow: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.card:hover {
  box-shadow: var(--crm-shadow-md);
}
.card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--crm-border-light);
  padding: 0.85rem 1rem 0.5rem;
}
.card-header .card-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--crm-text);
  letter-spacing: 0;
}
.card-body {
  padding: 1rem;
}

/* Stat cards — sin lift */
.card.stat-card:hover {
  transform: none;
  box-shadow: var(--crm-shadow-md);
}

/* ── Modern badges (chip style) ────────────── */
.badge {
  font-weight: 500;
  border-radius: 8px;
  letter-spacing: 0.01em;
}
.badge.badge-chip {
  border-radius: 50rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Buttons — flat (sin degradado) ───────── */
.btn {
  --btn-shadow: none;
  --btn-shadow-hover: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: var(--crm-radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  line-height: 1.25;
  border-width: 1.5px;
  box-shadow: none;
  transition:
    color 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crm-accent) 28%, transparent);
}
.btn:active {
  transform: none;
  filter: brightness(0.96);
}
.btn.btn-lg {
  padding: 0.7rem 1.35rem;
  font-size: 0.9375rem;
  border-radius: var(--crm-radius-sm);
  letter-spacing: 0.015em;
}
.btn.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: var(--crm-radius-xs);
}

/* Primary — flat sólido */
.btn-primary {
  background-color: var(--crm-accent);
  background-image: none;
  border-color: var(--crm-accent);
  color: #fff;
  box-shadow: none;
}
.btn-primary:hover,
.btn-primary:focus-visible {
  background-color: var(--crm-accent-hover);
  background-image: none;
  border-color: var(--crm-accent-hover);
  color: #fff;
  box-shadow: none;
  transform: none;
}
.btn-primary:active {
  background-color: var(--crm-accent-hover);
  background-image: none;
  box-shadow: none;
  transform: none;
  filter: brightness(0.96);
}

/* Success — flat sólido */
.btn-success {
  background-color: var(--crm-success);
  background-image: none;
  border-color: var(--crm-success);
  color: #fff;
  box-shadow: none;
}
.btn-success:hover,
.btn-success:focus-visible {
  background-color: var(--crm-success-hover);
  background-image: none;
  border-color: var(--crm-success-hover);
  color: #fff;
  box-shadow: none;
  transform: none;
}
.btn-success:active {
  background-color: var(--crm-success-hover);
  background-image: none;
  box-shadow: none;
  transform: none;
  filter: brightness(0.96);
}

/* Danger — flat sólido */
.btn-danger {
  background-color: var(--crm-danger);
  background-image: none;
  border-color: var(--crm-danger);
  color: #fff;
  box-shadow: none;
}
.btn-danger:hover,
.btn-danger:focus-visible {
  background-color: var(--crm-danger-hover);
  background-image: none;
  border-color: var(--crm-danger-hover);
  color: #fff;
  box-shadow: none;
  transform: none;
}
.btn-danger:active {
  background-color: var(--crm-danger-hover);
  background-image: none;
  box-shadow: none;
  transform: none;
  filter: brightness(0.96);
}

/* Warning — flat sólido */
.btn-warning {
  background-color: var(--crm-warning);
  background-image: none;
  border-color: var(--crm-warning);
  color: #fff;
  box-shadow: none;
}
.btn-warning:hover,
.btn-warning:focus-visible {
  background-color: var(--crm-warning-hover);
  background-image: none;
  border-color: var(--crm-warning-hover);
  color: #fff;
  box-shadow: none;
  transform: none;
}
.btn-warning:active {
  background-color: var(--crm-warning-hover);
  background-image: none;
  box-shadow: none;
  transform: none;
  filter: brightness(0.96);
}

/* Info — flat sólido */
.btn-info {
  background-color: var(--crm-info);
  background-image: none;
  border-color: var(--crm-info);
  color: #fff;
  box-shadow: none;
}
.btn-info:hover,
.btn-info:focus-visible {
  background-color: var(--crm-info-hover);
  background-image: none;
  border-color: var(--crm-info-hover);
  color: #fff;
  box-shadow: none;
  transform: none;
}
.btn-info:active {
  background-color: var(--crm-info-hover);
  background-image: none;
  box-shadow: none;
  transform: none;
  filter: brightness(0.96);
}

/* Outline primary */
.btn-outline-primary {
  color: var(--crm-accent);
  border-color: color-mix(in srgb, var(--crm-accent) 40%, var(--crm-border));
  background-color: transparent;
  background-image: none;
  box-shadow: none;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus-visible {
  color: var(--crm-accent-hover);
  background-color: var(--crm-accent-light);
  background-image: none;
  border-color: var(--crm-accent);
  box-shadow: none;
  transform: none;
}

/* Outline secondary */
.btn-outline-secondary {
  color: var(--crm-text-secondary);
  border-color: var(--crm-border);
  background-color: transparent;
  background-image: none;
  box-shadow: none;
}
.btn-outline-secondary:hover,
.btn-outline-secondary:focus-visible {
  color: var(--crm-text);
  background-color: var(--crm-hover);
  background-image: none;
  border-color: var(--crm-text-muted);
  box-shadow: none;
  transform: none;
}

/* Outline danger */
.btn-outline-danger {
  color: var(--crm-danger);
  border-color: color-mix(in srgb, var(--crm-danger) 35%, var(--crm-border));
  background-color: transparent;
  background-image: none;
  box-shadow: none;
}
.btn-outline-danger:hover,
.btn-outline-danger:focus-visible {
  color: var(--crm-danger-hover);
  background-color: color-mix(in srgb, var(--crm-danger) 10%, transparent);
  background-image: none;
  border-color: color-mix(in srgb, var(--crm-danger) 50%, var(--crm-border));
  box-shadow: none;
  transform: none;
}

/* Outline success */
.btn-outline-success {
  color: var(--crm-success);
  border-color: color-mix(in srgb, var(--crm-success) 35%, var(--crm-border));
  background-color: transparent;
  background-image: none;
  box-shadow: none;
}
.btn-outline-success:hover,
.btn-outline-success:focus-visible {
  color: var(--crm-success-hover);
  background-color: color-mix(in srgb, var(--crm-success) 10%, transparent);
  background-image: none;
  border-color: color-mix(in srgb, var(--crm-success) 50%, var(--crm-border));
  box-shadow: none;
  transform: none;
}

/* Outline warning */
.btn-outline-warning {
  color: var(--crm-warning);
  border-color: color-mix(in srgb, var(--crm-warning) 35%, var(--crm-border));
  background-color: transparent;
  background-image: none;
  box-shadow: none;
}
.btn-outline-warning:hover,
.btn-outline-warning:focus-visible {
  color: var(--crm-warning-hover);
  background-color: color-mix(in srgb, var(--crm-warning) 10%, transparent);
  background-image: none;
  border-color: color-mix(in srgb, var(--crm-warning) 50%, var(--crm-border));
  box-shadow: none;
  transform: none;
}

/* Outline info */
.btn-outline-info {
  color: var(--crm-info);
  border-color: color-mix(in srgb, var(--crm-info) 35%, var(--crm-border));
  background-color: transparent;
  background-image: none;
  box-shadow: none;
}
.btn-outline-info:hover,
.btn-outline-info:focus-visible {
  color: var(--crm-info-hover);
  background-color: color-mix(in srgb, var(--crm-info) 10%, transparent);
  background-image: none;
  border-color: color-mix(in srgb, var(--crm-info) 50%, var(--crm-border));
  box-shadow: none;
  transform: none;
}

/* Ghost / light */
.btn-light {
  background-color: var(--crm-surface);
  background-image: none;
  border-color: var(--crm-border);
  color: var(--crm-text-secondary);
  box-shadow: none;
}
.btn-light:hover,
.btn-light:focus-visible {
  background-color: var(--crm-hover);
  background-image: none;
  border-color: var(--crm-border);
  color: var(--crm-text);
  transform: none;
  box-shadow: none;
}

/* Compact icon-only action buttons (tables, toolbars) */
.btn-action {
  --btn-action-size: 2.125rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--btn-action-size);
  height: var(--btn-action-size);
  padding: 0;
  flex-shrink: 0;
  border-radius: var(--crm-radius-xs);
  border: 1.5px solid transparent;
  background-color: var(--crm-surface-alt);
  color: var(--crm-text-muted);
  font-size: 0.8125rem;
  line-height: 1;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
  transition:
    color 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}
.btn-action i {
  display: block;
  line-height: 1;
  pointer-events: none;
}
.btn-action:hover,
.btn-action:focus-visible {
  transform: none;
}
.btn-action.btn-action-view:hover,
.btn-action.btn-action-view:focus-visible {
  color: var(--crm-text-secondary);
  background-color: var(--crm-hover);
  border-color: var(--crm-border);
  box-shadow: none;
}
.btn-action.btn-action-edit {
  color: var(--crm-accent);
  background-color: var(--crm-accent-light);
}
.btn-action.btn-action-edit:hover,
.btn-action.btn-action-edit:focus-visible {
  color: #fff;
  background-color: var(--crm-accent);
  border-color: transparent;
  box-shadow: none;
}
.btn-action.btn-action-delete {
  color: var(--crm-danger);
  background-color: color-mix(in srgb, var(--crm-danger) 8%, transparent);
}
.btn-action.btn-action-delete:hover,
.btn-action.btn-action-delete:focus-visible {
  color: #fff;
  background-color: var(--crm-danger);
  border-color: transparent;
  box-shadow: none;
}
[data-bs-theme="dark"] .btn-action.btn-action-delete {
  color: var(--crm-danger);
  background-color: color-mix(in srgb, var(--crm-danger) 12%, transparent);
}

/* Inline action group */
.btn-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.btn-actions .button_to {
  display: inline-flex;
  margin: 0;
}

/* Mobile action buttons with label */
.btn-action-label {
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
  border-radius: var(--crm-radius-xs);
  border-width: 1.5px;
  font-weight: 600;
}
.btn-action-label.btn-outline-secondary {
  background-color: var(--crm-surface-alt);
}
.btn-action-label.btn-outline-primary {
  background-color: var(--crm-accent-light);
}
.btn-action-label.btn-outline-danger {
  background-color: color-mix(in srgb, var(--crm-danger) 6%, transparent);
}

[data-bs-theme="dark"] .btn-outline-secondary:hover,
[data-bs-theme="dark"] .btn-outline-secondary:focus-visible {
  border-color: var(--crm-text-muted);
  box-shadow: none;
}
[data-bs-theme="dark"] .btn-outline-primary {
  border-color: color-mix(in srgb, var(--crm-accent) 40%, var(--crm-border));
}
[data-bs-theme="dark"] .btn-primary {
  background-color: var(--crm-accent);
  background-image: none;
  border-color: var(--crm-accent);
  box-shadow: none;
}
[data-bs-theme="dark"] .btn-primary:hover,
[data-bs-theme="dark"] .btn-primary:focus-visible {
  background-color: var(--crm-accent-hover);
  background-image: none;
  border-color: var(--crm-accent-hover);
  box-shadow: none;
}
[data-bs-theme="dark"] .btn-action {
  background-color: var(--crm-surface-alt);
}
[data-bs-theme="dark"] .btn-action.btn-action-view:hover,
[data-bs-theme="dark"] .btn-action.btn-action-view:focus-visible {
  box-shadow: none;
}

/* Solid semantic buttons — dark mode: oscurecer para contraste con texto blanco */
[data-bs-theme="dark"] .btn-success {
  background-color: color-mix(in srgb, var(--crm-success) 55%, #000);
  border-color: color-mix(in srgb, var(--crm-success) 55%, #000);
  color: #fff;
}
[data-bs-theme="dark"] .btn-success:hover,
[data-bs-theme="dark"] .btn-success:focus-visible,
[data-bs-theme="dark"] .btn-success:active {
  background-color: color-mix(in srgb, var(--crm-success) 65%, #000);
  border-color: color-mix(in srgb, var(--crm-success) 65%, #000);
  color: #fff;
}
[data-bs-theme="dark"] .btn-danger {
  background-color: color-mix(in srgb, var(--crm-danger) 50%, #000);
  border-color: color-mix(in srgb, var(--crm-danger) 50%, #000);
  color: #fff;
}
[data-bs-theme="dark"] .btn-danger:hover,
[data-bs-theme="dark"] .btn-danger:focus-visible,
[data-bs-theme="dark"] .btn-danger:active {
  background-color: color-mix(in srgb, var(--crm-danger) 60%, #000);
  border-color: color-mix(in srgb, var(--crm-danger) 60%, #000);
  color: #fff;
}
[data-bs-theme="dark"] .btn-warning {
  background-color: color-mix(in srgb, var(--crm-warning) 50%, #000);
  border-color: color-mix(in srgb, var(--crm-warning) 50%, #000);
  color: #fff;
}
[data-bs-theme="dark"] .btn-warning:hover,
[data-bs-theme="dark"] .btn-warning:focus-visible,
[data-bs-theme="dark"] .btn-warning:active {
  background-color: color-mix(in srgb, var(--crm-warning) 60%, #000);
  border-color: color-mix(in srgb, var(--crm-warning) 60%, #000);
  color: #fff;
}
[data-bs-theme="dark"] .btn-info {
  background-color: color-mix(in srgb, var(--crm-info) 45%, #000);
  border-color: color-mix(in srgb, var(--crm-info) 45%, #000);
  color: #fff;
}
[data-bs-theme="dark"] .btn-info:hover,
[data-bs-theme="dark"] .btn-info:focus-visible,
[data-bs-theme="dark"] .btn-info:active {
  background-color: color-mix(in srgb, var(--crm-info) 55%, #000);
  border-color: color-mix(in srgb, var(--crm-info) 55%, #000);
  color: #fff;
}

/* Filter / submit CTA inside cards */
.btn-filter {
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  border-radius: var(--crm-radius-sm);
}

/* ── Progress bars ────────────────────────── */
.progress {
  height: 8px;
  border-radius: 50rem;
  background-color: var(--crm-surface-alt);
}
.progress-bar {
  border-radius: 50rem;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
@media (min-width: 992px) {
  .progress {
    height: 10px;
  }
}

/* ── List groups ──────────────────────────── */
.list-group-item {
  border-color: var(--crm-border);
  background-color: transparent;
  transition: background-color 0.15s ease;
}
.list-group-item:hover {
  background-color: var(--crm-hover);
}
.list-group-item:last-child {
  border-bottom: none;
}

/* ── Forms ────────────────────────────────── */
.form-control {
  border-color: var(--crm-border);
  border-radius: var(--crm-radius-sm);
  padding: 0.65rem 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-control:focus {
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--crm-accent) 18%, transparent);
}
.form-label {
  font-weight: 600;
  color: var(--crm-text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

/* ── Dropdowns ────────────────────────────── */
.dropdown-menu {
  border: 1px solid var(--crm-border);
  box-shadow: var(--crm-shadow-md);
  border-radius: var(--crm-radius-sm);
  padding: 0.5rem;
}
.dropdown-item {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--crm-text);
  border-radius: var(--crm-radius-xs);
  padding: 0.5rem 0.85rem;
  transition: background-color 0.15s ease;
}
.dropdown-item:hover {
  background-color: var(--crm-hover);
  color: var(--crm-text);
}

/* ── Table modernization ──────────────────── */
.table thead th {
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--crm-text-muted);
  border-bottom-width: 1px;
  padding: 1rem 1.25rem;
}
.table tbody td {
  padding: 1rem 1.25rem;
  vertical-align: middle;
  color: var(--crm-text);
}
.table tbody tr {
  transition: background-color 0.15s ease;
}

/* ── Empty states ─────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}
.empty-state i {
  font-size: 4rem;
  color: var(--crm-text-muted);
  opacity: 0.4;
}
.empty-state h5 {
  font-weight: 700;
  color: var(--crm-text-secondary);
  margin-top: 1.25rem;
}
.empty-state p {
  color: var(--crm-text-muted);
  font-size: 0.95rem;
}

/* ── Password validator requirements ─────── */
.password-requirements {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--crm-surface-alt);
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
}
.password-requirements p {
  margin: 0 0 0.375rem 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--crm-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.password-requirements ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.password-requirements li {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--crm-text-muted);
  transition: color 0.2s ease;
}
.password-requirements li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.2em;
  width: 0.75rem;
  height: 0.75rem;
  border: 1.5px solid var(--crm-border);
  border-radius: 50%;
  transition: all 0.2s ease;
  text-align: center;
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 0.75rem;
  color: transparent;
}
.password-requirements li.met {
  color: #059669;
}
.password-requirements li.met::before {
  content: "\2714";
  background: #22c55e;
  border-color: #22c55e;
  color: #ffffff;
}
.password-requirements li.unmet {
  color: #ef4444;
}
.password-requirements li.unmet::before {
  content: "\2717";
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
}
[data-bs-theme="dark"] .password-requirements li.met::before {
  background: #34d399;
  border-color: #34d399;
}
[data-bs-theme="dark"] .password-requirements li.unmet::before {
  background: #f87171;
  border-color: #f87171;
}

/* ═══════════════════════════════════════════
   Pipeline metrics — software dense / mobile chips
   ═══════════════════════════════════════════ */
.sc-pipeline-metrics {
  margin: 0 0 0.85rem;
  width: 100%;
  min-width: 0;
}
.sc-pipeline-metrics__track {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 0.15rem 0 0.35rem;
  margin: 0 -0.15rem;
}
.sc-pipeline-metrics__track::-webkit-scrollbar {
  display: none;
}
.sc-pipeline-metric {
  flex: 0 0 auto;
  min-width: 7.25rem;
  padding: 0.55rem 0.75rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.sc-pipeline-metric__label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
  line-height: 1.2;
}
.sc-pipeline-metric__value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--crm-text);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.sc-pipeline-metric__value--mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
}
.sc-pipeline-metric--alert .sc-pipeline-metric__value {
  color: var(--crm-danger);
}
.sc-pipeline-metric--warn .sc-pipeline-metric__value {
  color: var(--crm-warning);
}
.sc-pipeline-metric--bottleneck.is-active {
  border-color: color-mix(in srgb, var(--crm-bottleneck) 55%, var(--crm-border));
  background: var(--crm-bottleneck-bg);
}
.sc-pipeline-metric--bottleneck.is-active .sc-pipeline-metric__value {
  color: var(--crm-bottleneck);
  font-size: 0.82rem;
}
@media (min-width: 768px) {
  .sc-pipeline-metrics__track {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: visible;
    margin: 0;
    padding: 0;
    gap: 0.65rem;
  }
  .sc-pipeline-metric {
    min-width: 0;
    flex: 1 1 0;
  }
}

/* ═══════════════════════════════════════════
   Kanban — software CRM, mobile first
   ═══════════════════════════════════════════ */
.admin-content:has(.kanban-board) {
  overflow-x: clip;
}
.kanban-board {
  overflow: visible;
  padding: 0.5rem 0 1.5rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 70vh;
  height: auto;
  background: transparent;
  cursor: grab;
}
.kanban-board.is-grabbing,
.kanban-hscroll-viewport.is-grabbing {
  cursor: grabbing;
  user-select: none;
}
.kanban-board.is-grabbing .kanban-card,
.kanban-hscroll-viewport.is-grabbing .kanban-card {
  cursor: grabbing;
}

/* Stage navigator — jump between pipeline columns */
.kanban-stage-nav {
  position: sticky;
  top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px));
  z-index: 35;
  margin: 0 0 0.45rem;
  padding: 0.35rem 0 0.15rem;
  background: color-mix(in srgb, var(--crm-bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.kanban-stage-nav__track {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding: 0.1rem 0.15rem 0.35rem;
  margin: 0 -0.1rem;
}
.kanban-stage-nav__track::-webkit-scrollbar {
  display: none;
}
.kanban-stage-nav__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  min-height: 2.75rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--crm-border);
  border-radius: 999px;
  background: var(--crm-surface);
  color: var(--crm-text-secondary);
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: 0.01em;
  scroll-snap-align: start;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.kanban-stage-nav__btn:hover,
.kanban-stage-nav__btn:focus-visible {
  background: var(--crm-hover);
  color: var(--crm-text);
  border-color: color-mix(in srgb, var(--crm-accent) 40%, var(--crm-border));
  outline: none;
}
.kanban-stage-nav__btn:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crm-accent) 22%, transparent);
}
.kanban-stage-nav__btn.is-active {
  color: var(--crm-text);
  border-color: color-mix(in srgb, var(--crm-accent) 55%, var(--crm-border));
  background: color-mix(in srgb, var(--crm-accent) 12%, var(--crm-surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--crm-accent) 25%, transparent);
}
.kanban-stage-nav__btn--bottleneck {
  border-color: color-mix(in srgb, var(--crm-bottleneck) 45%, var(--crm-border));
}
.kanban-stage-nav__btn--bottleneck.is-active {
  background: color-mix(in srgb, var(--crm-bottleneck-bg) 70%, var(--crm-surface));
  border-color: color-mix(in srgb, var(--crm-bottleneck) 55%, var(--crm-border));
}
.kanban-stage-nav__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.kanban-stage-nav__label {
  white-space: nowrap;
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kanban-stage-nav__count {
  min-width: 1.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--crm-border);
  color: var(--crm-text-secondary);
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}
.kanban-stage-nav__btn.is-active .kanban-stage-nav__count {
  background: color-mix(in srgb, var(--crm-accent) 22%, var(--crm-border));
  color: var(--crm-text);
}
.kanban-stage-nav__hint {
  margin: 0;
  padding: 0 0.2rem 0.1rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
}

.kanban-sticky-headers {
  position: sticky;
  top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px) + 4.5rem);
  z-index: 30;
  overflow: hidden;
  margin-bottom: 0.35rem;
  background-color: var(--crm-bg);
}
/* Boards without stage nav keep classic sticky offset */
.kanban-board:not(:has(.kanban-stage-nav)) .kanban-sticky-headers {
  top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px));
}
.kanban-headers-track {
  width: max-content;
  min-width: 100%;
  will-change: transform;
}
.kanban-sticky-headers .kanban-stage-header {
  position: static;
  top: auto;
  z-index: auto;
  margin: 0;
  padding: 0.5rem 0.65rem;
  border-bottom: none;
  box-shadow: none;
}
.kanban-hscroll-viewport {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  scroll-padding-left: 0.35rem;
  scroll-padding-right: 1.25rem;
  scrollbar-gutter: stable;
  padding-bottom: 0.35rem;
  cursor: grab;
  /* Soft edge hint: more columns to the right */
  mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.25rem), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.25rem), transparent 100%);
}
.kanban-hscroll-viewport::-webkit-scrollbar {
  height: 8px;
}
.kanban-hscroll-viewport::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--crm-border) 35%, transparent);
  border-radius: 999px;
}
.kanban-hscroll-viewport::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--crm-text-muted) 55%, var(--crm-border));
  border-radius: 999px;
}
.kanban-hscroll-viewport::-webkit-scrollbar-thumb:hover {
  background: var(--crm-text-muted);
}
.kanban-row {
  display: flex;
  flex-wrap: nowrap !important;
  align-items: flex-start;
  gap: 0.65rem;
  width: max-content;
  min-width: 100%;
  margin-left: 0;
  margin-right: 0;
  --bs-gutter-x: 0;
  --bs-gutter-y: 0;
  padding-right: 1rem;
}

/* Column sizing — mobile first (next column peeks) */
.kanban-row > .kanban-column-wrapper,
.kanban-column-wrapper {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  flex: 0 0 min(88vw, 340px);
  width: min(88vw, 340px);
  min-width: min(88vw, 340px);
  max-width: min(88vw, 340px);
  padding-left: 0;
  padding-right: 0;
  margin-top: 0;
}
.kanban-column {
  display: flex;
  flex-direction: column;
  background-color: color-mix(in srgb, var(--crm-surface) 55%, var(--crm-bg));
  border-radius: 12px;
  height: auto;
  padding: 0.35rem 0.35rem 0.5rem;
  border: 1px solid var(--crm-border);
  transition: background 0.2s ease, border-color 0.2s ease;
}

/* Stage header */
.kanban-stage-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: sticky;
  top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px));
  z-index: 25;
  margin: 0 0 0.4rem;
  padding: 0.5rem 0.55rem;
  background-color: color-mix(in srgb, var(--crm-surface) 55%, var(--crm-bg));
  border-radius: 10px;
  min-height: 2.75rem;
}
.kanban-stage-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kanban-stage-title {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--crm-text);
  letter-spacing: -0.01em;
  text-transform: uppercase;
}
.kanban-stage-count {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--crm-text-secondary);
  background-color: var(--crm-border);
  padding: 0.1rem 0.5rem;
  border-radius: 50rem;
  flex-shrink: 0;
  min-width: 1.5rem;
  text-align: center;
}
.kanban-stage-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.kanban-stage-amount {
  font-size: 0.65rem;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--crm-text-muted);
  max-width: 4.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kanban-stage-archive-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--crm-text-muted);
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.35rem;
  border-radius: var(--crm-radius-xs);
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.kanban-stage-archive-btn:hover,
.kanban-stage-archive-btn:focus-visible {
  background-color: var(--crm-hover);
  color: var(--crm-text);
}
.kanban-bottleneck-badge {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--crm-bottleneck);
  background: var(--crm-bottleneck-bg);
  border: 1px solid color-mix(in srgb, var(--crm-bottleneck) 35%, transparent);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
}
.kanban-column-wrapper--bottleneck .kanban-stage-header--bottleneck,
.kanban-stage-header--bottleneck {
  border: 1px solid color-mix(in srgb, var(--crm-bottleneck) 45%, var(--crm-border));
  background: color-mix(in srgb, var(--crm-bottleneck-bg) 70%, var(--crm-surface));
  box-shadow: inset 3px 0 0 var(--crm-bottleneck);
}
.kanban-column--bottleneck {
  border-color: color-mix(in srgb, var(--crm-bottleneck) 40%, var(--crm-border));
  background-color: color-mix(in srgb, var(--crm-bottleneck-bg) 35%, var(--crm-surface));
}
.kanban-status-badge {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  line-height: 1.2;
}
.kanban-status-badge--overdue {
  color: var(--crm-danger);
  background: color-mix(in srgb, var(--crm-danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--crm-danger) 28%, transparent);
}
.kanban-status-badge--stale {
  color: var(--crm-warning);
  background: var(--crm-bottleneck-bg);
  border: 1px solid color-mix(in srgb, var(--crm-warning) 28%, transparent);
}
.kanban-card--overdue {
  border-color: color-mix(in srgb, var(--crm-danger) 40%, var(--crm-border));
  border-left-color: var(--crm-danger);
}
.kanban-card--stale {
  border-color: color-mix(in srgb, var(--crm-warning) 35%, var(--crm-border));
  border-left-color: var(--crm-warning);
}
.kanban-card-date--overdue {
  color: var(--crm-danger) !important;
  font-weight: 700;
}
.kanban-tag--mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.kanban-card-quote-btn {
  border-radius: var(--crm-radius-xs) !important;
  font-size: 0.75rem;
  font-weight: 600;
  min-height: 2.25rem;
}
.kanban-card-report-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.45rem;
}
.kanban-card-report-actions__buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}
.kanban-card-report-actions__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border-radius: var(--crm-radius-xs) !important;
  font-size: 0.72rem;
  font-weight: 600;
  min-height: 2.5rem;
  padding: 0.35rem 0.4rem;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.kanban-card-report-actions__btn--icon {
  font-size: 0.95rem;
  line-height: 1;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0;
}
.kanban-card-report-actions__btn--icon:disabled,
.kanban-card-report-actions__btn--icon[aria-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
}
.kanban-card-report-actions__hint {
  font-size: 0.7rem;
  line-height: 1.3;
}
.kanban-card-not-proceeded-btn {
  border-radius: var(--crm-radius-xs) !important;
  font-size: 0.75rem;
  font-weight: 600;
  min-height: 2.25rem;
  color: var(--crm-danger);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--crm-danger) 45%, transparent);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.kanban-card-not-proceeded-btn:hover,
.kanban-card-not-proceeded-btn:focus-visible {
  background: color-mix(in srgb, var(--crm-danger) 10%, transparent);
  border-color: var(--crm-danger);
  color: var(--crm-danger);
}
.sales-cycle-not-proceeded-btn {
  color: var(--crm-danger);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--crm-danger) 45%, transparent);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.sales-cycle-not-proceeded-btn:hover,
.sales-cycle-not-proceeded-btn:focus-visible {
  background: color-mix(in srgb, var(--crm-danger) 10%, transparent);
  border-color: var(--crm-danger);
  color: var(--crm-danger);
}
/* Not proceeded overlay — viewport-fixed, escapes kanban overflow/flex */
.sc-not-proceeded {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-top: calc(1rem + env(safe-area-inset-top, 0px));
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}
.sc-not-proceeded[hidden] {
  display: none !important;
}
.sc-not-proceeded__backdrop {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: color-mix(in srgb, var(--crm-text) 45%, transparent);
  cursor: pointer;
  z-index: 0;
}
.sc-not-proceeded__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(32rem, 100%);
  max-height: calc(100dvh - 2rem);
  background: var(--crm-surface);
  color: var(--crm-text);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  box-shadow: var(--crm-shadow-lg);
  overflow: hidden;
}
.sc-not-proceeded__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--crm-border);
  background: var(--crm-surface);
}
.sc-not-proceeded__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--crm-text);
  min-width: 0;
}
.sc-not-proceeded__body {
  padding: 1.25rem;
  overflow-y: auto;
  color: var(--crm-text);
}
.sc-not-proceeded__body .form-text.text-muted {
  color: var(--crm-text-muted) !important;
}
.sc-not-proceeded__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-shrink: 0;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--crm-border);
}
.sc-not-proceeded .crm-field-label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
  color: var(--crm-text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sc-not-proceeded .form-control,
.sc-not-proceeded .form-select {
  background: var(--crm-surface);
  color: var(--crm-text);
  border-color: var(--crm-border);
  border-radius: var(--crm-radius-xs);
}
.sc-not-proceeded .form-control:focus,
.sc-not-proceeded .form-select:focus {
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crm-accent) 18%, transparent);
}
body.sc-not-proceeded-open {
  overflow: hidden;
}
.kanban-stage-menu {
  background: transparent;
  border: none;
  color: var(--crm-text-secondary);
  padding: 0.25rem 0.45rem;
  border-radius: var(--crm-radius-xs);
  font-size: 0.8rem;
  transition: background-color 0.2s ease;
}
.kanban-stage-menu:hover {
  background-color: var(--crm-border);
  color: var(--crm-text);
}

/* Task list */
.kanban-tasks {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 40px;
  flex: 0 0 auto;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  border-radius: 8px;
  padding: 0.15rem;
}
.kanban-tasks.drag-over {
  background-color: color-mix(in srgb, var(--crm-accent) 12%, transparent);
  box-shadow: inset 0 0 0 2px var(--crm-accent);
}
.kanban-tasks--empty {
  min-height: 5.5rem;
  justify-content: center;
}
.kanban-empty-column {
  margin: 0;
  padding: 1.1rem 0.75rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--crm-text-muted);
  border: 1px dashed var(--crm-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--crm-surface) 40%, transparent);
}

/* Kanban cards — flat, Trello-like (tap to open; stages are not draggable) */
.kanban-card {
  background: var(--crm-surface);
  border-radius: 8px;
  padding: 0.6rem 0.7rem 0.6rem 0.85rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
  border: 1px solid var(--crm-border);
  border-left: 4px solid var(--sc-priority-color, #94a3b8);
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.kanban-card:hover {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.14);
  border-color: color-mix(in srgb, var(--crm-accent) 45%, var(--crm-border));
  border-left-color: var(--sc-priority-color, var(--crm-accent));
}
.kanban-card:active {
  cursor: pointer;
  transform: scale(0.995);
}
.kanban-card.dragging {
  opacity: 0.65;
  transform: rotate(1.5deg);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.22);
}

/* Card priority — shared indicator (Kanban + Calendar) */
.priority-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  color: var(--crm-text-secondary);
}
.priority-indicator__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--sc-priority-color, #94a3b8);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--sc-priority-color, #94a3b8) 25%, transparent);
}
.priority-indicator.priority-high {
  --sc-priority-color: #b91c1c;
}
.priority-indicator.priority-medium {
  --sc-priority-color: #b45309;
}
.priority-indicator.priority-low {
  --sc-priority-color: #94a3b8;
}
.priority-indicator__label {
  letter-spacing: 0.01em;
}

/* Kanban card — colored left stripe by priority (replaces old 2px top bar) */
.kanban-card--priority-high,
.kanban-card--priority-medium,
.kanban-card--priority-low {
  /* stripe handled via border-left on .kanban-card using --sc-priority-color */
}

/* Labels row — Trello-style chips (priority + stage + status) */
.kanban-card__labels {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.4rem;
}
.kanban-priority-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  border-radius: 50rem;
  color: var(--sc-priority-color, var(--crm-text-secondary));
  background: color-mix(in srgb, var(--sc-priority-color, #94a3b8) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--sc-priority-color, #94a3b8) 35%, transparent);
  flex-shrink: 0;
}
.kanban-priority-chip__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--sc-priority-color, #94a3b8);
  flex-shrink: 0;
}
.kanban-stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  padding: 0.18rem 0.5rem;
  border-radius: 50rem;
  color: var(--crm-text-secondary);
  background: color-mix(in srgb, var(--sc-stage-color, #64748b) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--sc-stage-color, #64748b) 25%, transparent);
  flex-shrink: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* En móvil el chip de etapa es redundante (ya estás en la columna) */
.kanban-stage-chip--desktop {
  display: none;
}
@media (min-width: 768px) {
  .kanban-stage-chip--desktop {
    display: inline-flex;
  }
}
.kanban-stage-chip__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--sc-stage-color, #64748b);
  flex-shrink: 0;
}

/* Legacy pill — kept for demo kanban and repair cycles */
.kanban-card-priority {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 50rem;
}
.kanban-card-priority.priority-high {
  color: #e63946;
  background-color: rgba(230, 57, 70, 0.12);
}
.kanban-card-priority.priority-medium {
  color: #c98a0e;
  background-color: rgba(230, 168, 23, 0.14);
}
.kanban-card-priority.priority-low {
  color: var(--crm-text-muted);
  background-color: rgba(108, 112, 128, 0.12);
}

/* Card menu — always visible on touch (no hover); 44px targets */
.kanban-card-menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--crm-text-muted);
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.35rem;
  border-radius: var(--crm-radius-xs);
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.kanban-card-menu:hover {
  background-color: var(--crm-hover);
  color: #e63946;
}
.kanban-card-menu--archive:hover {
  color: var(--crm-accent);
}

/* Card title */
.kanban-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--crm-text);
  margin-bottom: 0;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

/* Card tags */
.kanban-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.kanban-tag {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--crm-text-secondary);
  background-color: var(--crm-surface-alt);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  letter-spacing: 0.01em;
  border: 1px solid var(--crm-border);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.kanban-tag--customer i {
  color: var(--crm-accent);
}
.kanban-tag--quote i {
  color: var(--crm-success);
}

.kanban-tag--remission i {
  color: var(--crm-info);
}

/* Card header badge — quick visual cue for cycles with an attached quote */
.kanban-card-quote-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: var(--crm-radius-xs);
  color: var(--crm-success);
  background: color-mix(in srgb, var(--crm-success) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--crm-success) 30%, transparent);
  font-size: 0.62rem;
  line-height: 1;
  flex-shrink: 0;
  pointer-events: none;
}

/* Card meta */
.kanban-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0;
  padding-top: 0.45rem;
  border-top: 1px solid var(--crm-border);
  font-size: 0.8rem;
  color: var(--crm-text-secondary);
}
.kanban-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: color-mix(in srgb, var(--crm-accent) 18%, transparent);
  color: var(--crm-accent);
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--crm-accent) 35%, transparent);
}
.kanban-card-date {
  font-size: 0.72rem;
  color: var(--crm-text-muted);
  display: inline-flex;
  align-items: center;
}
.kanban-card-amount {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--crm-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kanban-card-amount i {
  color: var(--crm-warning);
  font-size: 0.7rem;
}

/* Add card button */
.kanban-add-card {
  width: 100%;
  text-align: center;
  padding: 0.6rem;
  color: var(--crm-text-muted);
  background-color: transparent;
  border: 1px dashed var(--crm-border);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s ease;
}
.kanban-add-card:hover {
  background-color: var(--crm-surface);
  color: var(--crm-accent);
  border-color: var(--crm-accent);
  border-style: solid;
}

/* Hide hover-only affordances on touch devices already handled by always-on.
   On devices that DO support hover, keep delete button subtle until hover. */
@media (hover: hover) and (pointer: fine) {
  .kanban-card-menu {
    opacity: 0;
  }
  .kanban-card:hover .kanban-card-menu,
  .kanban-card-menu:focus-visible {
    opacity: 1;
  }
}

/* Dark mode — chips con mayor saturación para que los colores "salten"
   sobre la superficie oscura. */
[data-bs-theme="dark"] .kanban-priority-chip {
  background: color-mix(in srgb, var(--sc-priority-color, #94a3b8) 24%, transparent);
  border-color: color-mix(in srgb, var(--sc-priority-color, #94a3b8) 45%, transparent);
  color: color-mix(in srgb, var(--sc-priority-color, #94a3b8) 75%, #ffffff 25%);
}
[data-bs-theme="dark"] .kanban-stage-chip {
  background: color-mix(in srgb, var(--sc-stage-color, #64748b) 18%, transparent);
  border-color: color-mix(in srgb, var(--sc-stage-color, #64748b) 40%, transparent);
  color: var(--crm-text);
}
[data-bs-theme="dark"] .kanban-card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
[data-bs-theme="dark"] .kanban-card:hover {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

/* Tablet and up — comfortable column width + softer snap */
@media (min-width: 768px) {
  .kanban-board {
    min-height: calc(100vh - 220px);
  }
  .kanban-row {
    gap: 0.85rem;
  }
  .kanban-row > .kanban-column-wrapper,
  .kanban-column-wrapper {
    flex: 0 0 min(46vw, 300px);
    width: min(46vw, 300px);
    min-width: min(46vw, 300px);
    max-width: min(46vw, 300px);
  }
  .kanban-stage-nav__hint {
    display: none;
  }
  .kanban-hscroll-viewport {
    scroll-snap-type: x proximity;
    mask-image: none;
    -webkit-mask-image: none;
  }
  .kanban-sticky-headers {
    top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px) + 3.25rem);
  }
}

@media (min-width: 992px) {
  .kanban-row > .kanban-column-wrapper,
  .kanban-column-wrapper {
    flex: 0 0 290px;
    width: 290px;
    min-width: 290px;
    max-width: 290px;
    scroll-snap-stop: normal;
  }
  .kanban-stage-nav__btn {
    min-height: 2.35rem;
  }
}

/* Turbo Native — stage nav sits under the native chrome / safe area */
body[data-turbo-native] .kanban-stage-nav {
  top: env(safe-area-inset-top, 0px);
}
body[data-turbo-native] .kanban-sticky-headers {
  top: calc(env(safe-area-inset-top, 0px) + 4.5rem);
}
body[data-turbo-native] .kanban-board:not(:has(.kanban-stage-nav)) .kanban-sticky-headers {
  top: env(safe-area-inset-top, 0px);
}
@media (min-width: 768px) {
  body[data-turbo-native] .kanban-sticky-headers {
    top: calc(env(safe-area-inset-top, 0px) + 3.25rem);
  }
}

[data-bs-theme="dark"] .kanban-stage-nav {
  background: color-mix(in srgb, var(--crm-bg) 88%, transparent);
}
[data-bs-theme="dark"] .kanban-stage-nav__btn.is-active {
  background: color-mix(in srgb, var(--crm-accent) 18%, var(--crm-surface));
}
[data-bs-theme="dark"] .kanban-empty-column {
  background: color-mix(in srgb, var(--crm-surface) 55%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .kanban-stage-nav__btn,
  .kanban-card {
    transition: none;
  }
}

/* ═══════════════════════════════════════════
   Trix editor — modern styling
   ═══════════════════════════════════════════ */
trix-editor {
  min-height: 180px;
  border: 1px solid var(--crm-border) !important;
  border-top: none !important;
  border-radius: 0 0 var(--crm-radius-sm) var(--crm-radius-sm) !important;
  padding: 1rem;
  background-color: var(--crm-surface);
  color: var(--crm-text);
  font-size: 0.95rem;
  line-height: 1.65;
}
trix-toolbar {
  background: var(--crm-trix-toolbar-bg) !important;
  border: 1px solid var(--crm-border) !important;
  border-bottom: none !important;
  border-radius: var(--crm-radius-sm) var(--crm-radius-sm) 0 0 !important;
  padding: 0.35rem 0.5rem;
}
trix-toolbar .trix-button-row {
  flex-wrap: wrap;
  gap: 0.15rem;
}
trix-toolbar .trix-button-group {
  margin-bottom: 0.25rem;
}
trix-toolbar .trix-button-group:not(:last-child) {
  margin-right: 0.35rem;
}
trix-toolbar .trix-button {
  border-radius: var(--crm-radius-xs) !important;
  color: var(--crm-text-secondary);
  transition: background-color 0.15s ease, color 0.15s ease;
}
trix-toolbar .trix-button-group {
  border-color: var(--crm-border);
  background-color: transparent;
}
trix-toolbar .trix-button:hover {
  background-color: var(--crm-hover);
  color: var(--crm-text);
}
trix-toolbar .trix-button.trix-active {
  background-color: var(--crm-accent-light);
  color: var(--crm-accent);
}
.trix-dialog {
  background: var(--crm-surface) !important;
  border-color: var(--crm-border) !important;
}
.trix-dialog .trix-input {
  background-color: var(--crm-surface) !important;
  border-color: var(--crm-border) !important;
  color: var(--crm-text);
}
.trix-dialog .trix-button--dialog {
  color: var(--crm-accent);
}
.trix-content a {
  color: var(--crm-accent);
}
.trix-content .attachment__caption,
.trix-content .attachment__name {
  color: var(--crm-text-muted);
}
.trix-content figure,
.trix-content .attachment {
  border-color: var(--crm-border);
}
.trix-content .attachment__caption-editor {
  background-color: var(--crm-surface-alt);
}
[data-bs-theme="dark"] trix-editor {
  background-color: var(--crm-surface-alt);
}
[data-bs-theme="dark"] trix-toolbar .trix-button {
  filter: invert(1) brightness(0.85);
}
[data-bs-theme="dark"] trix-toolbar .trix-button:hover {
  background-color: transparent !important;
}
[data-bs-theme="dark"] trix-toolbar .trix-button.trix-active {
  /* Los iconos son SVG de fondo: el fondo debe marcar el estado activo */
  background-color: var(--crm-accent-light) !important;
  box-shadow: inset 0 0 0 1px var(--crm-border);
  color: var(--crm-accent);
}

/* ═══════════════════════════════════════════
   Trix móvil — sales_cycles (teléfonos y tablets)
   Alcance: .sc-detail-view. Los colores base y el tema dark siguen
   en la sección "Trix editor — modern styling" de arriba.
   ═══════════════════════════════════════════ */
@media (max-width: 991.98px) {
  /* Botones con target táctil de 44px y sin retardo de tap */
  .sc-detail-view trix-toolbar .trix-button {
    min-width: 2.75rem;
    min-height: 2.75rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .sc-detail-view trix-toolbar .trix-button-group {
    margin-bottom: 0.35rem;
  }

  /* Escritura cómoda: 16px evita el auto-zoom de iOS al enfocar */
  .sc-detail-view trix-editor {
    font-size: 16px;
    line-height: 1.6;
    padding: 0.875rem 1rem;
    touch-action: manipulation;
  }

  .sc-detail-view trix-editor:focus-visible {
    outline: 2px solid var(--crm-accent);
    outline-offset: -2px;
  }

  /* Diálogo de enlace usable con el dedo */
  .sc-detail-view trix-toolbar .trix-dialog {
    font-size: 0.875rem;
  }

  .sc-detail-view trix-toolbar .trix-dialog .trix-input {
    min-height: 2.75rem;
    font-size: 16px;
  }

  .sc-detail-view trix-toolbar .trix-dialog .trix-button--dialog {
    min-width: 2.75rem;
    min-height: 2.75rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}

@media (max-width: 767.98px) {
  /* Una sola fila con scroll: ahorra alto vertical para el editor
     y el teclado (mismo patrón que .sc-detail-tabs-wrap) */
  .sc-detail-view trix-toolbar .trix-button-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.25rem;
    padding-bottom: 0.2rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.25rem), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.25rem), transparent 100%);
  }

  .sc-detail-view trix-toolbar .trix-button-row::-webkit-scrollbar {
    display: none;
  }

  .sc-detail-view trix-toolbar .trix-button-group {
    flex: 0 0 auto;
    margin-bottom: 0;
    scroll-snap-align: start;
  }

  .sc-detail-view trix-toolbar .trix-button-group:not(:last-child) {
    margin-right: 0.25rem;
  }

  /* Editor compacto con scroll interno: la página no crece sin límite */
  .sc-detail-view trix-editor {
    min-height: 8.75rem;
    max-height: 45dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Diálogo de enlace apilado a ancho completo */
  .sc-detail-view trix-toolbar .trix-dialog__link-fields {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  .sc-detail-view trix-toolbar .trix-dialog__link-fields .trix-input {
    flex: 1 1 100%;
  }

  .sc-detail-view trix-toolbar .trix-dialog__link-fields .trix-button-group {
    flex: 1 1 auto;
    justify-content: flex-end;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  /* En tablet hay ancho: se conserva el wrap (unas 2 filas) */
  .sc-detail-view trix-toolbar .trix-button-row {
    row-gap: 0.25rem;
  }

  .sc-detail-view trix-editor {
    min-height: 10rem;
    max-height: 50dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ═══════════════════════════════════════════
   Charts responsive
   ═══════════════════════════════════════════ */
canvas {
  max-height: 400px;
}

/* ═══════════════════════════════════════════
   Animations & effects
   ═══════════════════════════════════════════ */
@keyframes crm-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.animate-fade-in-up {
  animation: crm-fade-in-up 0.4s ease forwards;
}
.animate-delay-1 { animation-delay: 0.05s; opacity: 0; }
.animate-delay-2 { animation-delay: 0.10s; opacity: 0; }
.animate-delay-3 { animation-delay: 0.15s; opacity: 0; }
.animate-delay-4 { animation-delay: 0.20s; opacity: 0; }

/* Short fade-in reveal (e.g. extra fields shown after selecting a product) */
@keyframes crm-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.crm-quote-item-extra--visible {
  animation: crm-fade-in 0.25s ease forwards;
}

/* Fade-in reveal for the articles block after selecting a customer */
.crm-quote-items-block--visible {
  animation: crm-fade-in 0.3s ease forwards;
}

/* Pulse glow on stat icon */
@keyframes crm-pulse-glow {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.05); }
}
.stat-icon-glow {
  animation: crm-pulse-glow 2.5s ease-in-out infinite;
}

/* ── Desktop overrides ────────────────────── */
@media (min-width: 992px) {
  /* Sidebar: fixed to viewport, always visible */
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    transform: none;
    height: 100vh;
    width: var(--crm-sidebar-width);
    z-index: 1050;
    box-shadow: none;
  }
  .admin-sidebar.open {
    transform: none;
    box-shadow: none;
  }

  /* Main content: offset by sidebar width, natural scroll */
  .admin-main {
    margin-left: var(--crm-sidebar-width);
    width: auto;
    min-width: 0;
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  body.sidebar-collapsed .admin-main {
    margin-left: var(--crm-sidebar-collapsed);
  }

  .admin-wrapper {
    padding-top: 0;
  }

  .admin-sidebar-overlay {
    display: none !important;
  }

  /* Collapsed sidebar */
  .admin-sidebar.collapsed {
    width: var(--crm-sidebar-collapsed);
    overflow: visible;
  }
  .admin-sidebar.collapsed > .d-flex,
  .admin-sidebar.collapsed .sidebar-nav {
    overflow: visible;
  }
  .admin-sidebar.collapsed .sidebar-brand-text,
  .admin-sidebar.collapsed .nav-section-title,
  .admin-sidebar.collapsed .sidebar-footer {
    display: none !important;
  }
  /* Centrar y resaltar el botón chevron cuando está colapsado */
  .admin-sidebar.collapsed .p-3.d-none.d-lg-flex {
    justify-content: center !important;
  }
  .admin-sidebar.collapsed .sidebar-collapse-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--crm-radius-sm);
    background-color: var(--crm-sidebar-hover);
    color: var(--crm-sidebar-text);
  }
  .admin-sidebar.collapsed .sidebar-collapse-btn:hover {
    background-color: var(--crm-sidebar-active-bg);
    color: var(--crm-sidebar-active-text);
  }
  /* Ocultar solo etiquetas de texto; conservar iconos en ítems con submenú */
  .admin-sidebar.collapsed .nav-link .nav-link__label,
  .admin-sidebar.collapsed .nav-link:not(.nav-link--has-submenu) > span {
    display: none !important;
  }
  .admin-sidebar.collapsed .nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    margin-left: 0.35rem;
    margin-right: 0.35rem;
  }
  .admin-sidebar.collapsed .nav-link i {
    margin-right: 0;
  }
  /* Flyout de submenú en modo rail colapsado.
     position:fixed escapa overflow del nav; left/top/max-height los fija JS. */
  .admin-sidebar.collapsed [data-nav-target="submenuContainer"] {
    position: relative;
  }
  .admin-sidebar.collapsed .submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 220px;
    max-width: min(280px, calc(100vw - var(--crm-sidebar-collapsed) - 1rem));
    max-height: calc(100vh - 1rem);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0;
    padding: 0.35rem;
    background: var(--crm-sidebar-bg);
    border: 1px solid var(--crm-sidebar-border);
    border-radius: var(--crm-radius-sm);
    box-shadow: var(--crm-shadow-md);
    z-index: 1060;
    transition: none;
  }
  .admin-sidebar.collapsed .submenu.open {
    display: block;
    position: fixed;
    left: var(--submenu-flyout-left, calc(var(--crm-sidebar-collapsed) + 0.35rem));
    top: var(--submenu-flyout-top, 0.5rem);
    max-height: var(--submenu-flyout-max-height, calc(100vh - 1rem));
    overflow-y: auto;
    opacity: 1;
    padding: 0.35rem;
    border-left-color: var(--crm-sidebar-border);
    background: var(--crm-sidebar-bg);
  }
  .admin-sidebar.collapsed .submenu-toggle {
    display: none !important;
  }
  .admin-sidebar.collapsed .nav-link--has-submenu {
    justify-content: center !important;
  }
  .admin-sidebar.collapsed .nav-link--has-submenu .nav-link__content {
    display: flex !important;
    justify-content: center;
    gap: 0;
    flex: 0 0 auto;
  }

  /* Tooltip on hover for collapsed (solo enlaces de primer nivel) */
  .admin-sidebar.collapsed nav > .nav-link:not(.nav-link--has-submenu) {
    position: relative;
  }
  .admin-sidebar.collapsed nav > .nav-link:not(.nav-link--has-submenu)::after {
    content: attr(data-label);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--crm-sidebar-accent);
    color: #fff;
    padding: 0.4rem 0.7rem;
    border-radius: var(--crm-radius-xs);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    margin-left: 0.75rem;
    z-index: 1060;
    pointer-events: none;
    box-shadow: var(--crm-shadow-md);
  }
  .admin-sidebar.collapsed nav > .nav-link:not(.nav-link--has-submenu):hover::after {
    opacity: 1;
    visibility: visible;
  }

  /* Flyout items — texto visible y alineación normal */
  .admin-sidebar.collapsed .submenu .nav-link {
    justify-content: flex-start;
    margin: 0.1rem 0.35rem;
    padding: 0.45rem 0.75rem;
    width: auto;
  }
  .admin-sidebar.collapsed .submenu .nav-link > span {
    display: block !important;
  }
  .admin-sidebar.collapsed .submenu .nav-link i {
    width: 1.05rem;
    height: 1.05rem;
    font-size: 0.8rem;
  }
}

/* ── Mobile-first submenu overrides ───────── */
@media (max-width: 991.98px) {
  /* Off-screen drawer behaviour — mobile only */
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Alto dinámico: sigue a la toolbar del navegador; 100vh como fallback. */
    height: 100vh;
    height: 100dvh;
    /* .sidebar-nav es el único scroller vertical: sin scroll triple en táctil. */
    overflow: hidden;
    overscroll-behavior-y: contain;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
  }
  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--crm-shadow-lg);
  }
  .admin-sidebar .sidebar-nav {
    overscroll-behavior-y: contain;
  }
  .submenu {
    margin-left: 0.85rem;
    margin-right: 0.35rem;
  }
  .submenu.open {
    /* Altura dinámica inyectada por JS según el espacio bajo el botón;
       fallback en dvh (vh previo para navegadores sin soporte). */
    max-height: min(40rem, var(--submenu-expanded-max-height, calc(100vh - 8rem)));
    max-height: min(40rem, var(--submenu-expanded-max-height, calc(100dvh - 8rem)));
  }
  .submenu .nav-link {
    min-height: 2.75rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }
  .admin-sidebar .nav-link {
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
  }
}

/* ── Accessibility & motion ───────────────── */
@media (prefers-reduced-motion: reduce) {
  .admin-sidebar,
  .submenu,
  .admin-sidebar-overlay,
  .kanban-card,
  .card,
  .btn,
  .animate-fade-in-up,
  .crm-quote-item-extra--visible,
  .crm-quote-items-block--visible,
  .stat-icon-glow {
    animation: none !important;
    transition: none !important;
  }
}

/* ── Pagination (Kaminari) ────────────────── */
.crm-pagination-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  padding-top: 0.5rem;
}

.crm-pagination-meta {
  font-size: 0.85rem;
  line-height: 1.4;
}

.crm-pagination-per-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.crm-pagination-per-page-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.crm-pagination-per-page-group .btn {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.35rem 0.65rem;
  font-weight: 600;
  border-radius: var(--crm-radius-xs);
}

.crm-pagination-per-page-group .btn:first-child {
  border-top-left-radius: var(--crm-radius-sm);
  border-bottom-left-radius: var(--crm-radius-sm);
}

.crm-pagination-per-page-group .btn:last-child {
  border-top-right-radius: var(--crm-radius-sm);
  border-bottom-right-radius: var(--crm-radius-sm);
}

.crm-pagination-nav {
  width: 100%;
  display: flex;
  justify-content: center;
}

.crm-pagination-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.crm-pagination-item {
  display: flex;
}

.crm-pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-surface);
  color: var(--crm-text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.crm-pagination-link:hover {
  background: var(--crm-hover);
  border-color: var(--crm-accent);
  color: var(--crm-accent);
}

.crm-pagination-link.is-current {
  background: var(--crm-accent);
  border-color: var(--crm-accent);
  color: #fff;
  box-shadow: var(--crm-shadow-md);
}

.crm-pagination-link.is-gap {
  border-color: transparent;
  background: transparent;
  color: var(--crm-text-muted);
  min-width: 2rem;
  padding-inline: 0.25rem;
}

.crm-pagination-link--nav {
  padding-inline: 0.85rem;
}

.crm-pagination-nav-text {
  display: none;
}

@media (min-width: 576px) {
  .crm-pagination-bar {
    gap: 1.15rem;
  }

  .crm-pagination-per-page {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
  }

  .crm-pagination-nav-text {
    display: inline;
  }
}

@media (min-width: 768px) {
  .crm-pagination-bar {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    text-align: left;
  }

  .crm-pagination-meta {
    flex: 1 1 auto;
    text-align: left;
  }

  .crm-pagination-per-page {
    flex: 0 0 auto;
  }

  .crm-pagination-nav {
    flex: 1 1 100%;
    justify-content: center;
    margin-top: 0.25rem;
  }
}

@media (min-width: 992px) {
  .crm-pagination-bar {
    flex-wrap: nowrap;
    gap: 1.5rem;
  }

  .crm-pagination-nav {
    flex: 1 1 auto;
    margin-top: 0;
    justify-content: flex-end;
  }
}

/* ═══════════════════════════════════════════
   Detail / show pages — mobile-first + Turbo Native
   ═══════════════════════════════════════════ */

.crm-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
}

.crm-show-avatar {
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: var(--crm-accent-light);
  color: var(--crm-accent);
  font-weight: 700;
  font-size: 1rem;
}

.crm-show-hero__total {
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.crm-show-hero__breakdown {
  display: grid;
  gap: 0.5rem;
}

.crm-show-hero__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 0.9rem;
}

.crm-show-hero__row dt {
  margin: 0;
  color: var(--crm-text-muted);
  font-weight: 500;
}

.crm-show-hero__row dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.crm-detail-list {
  display: grid;
  gap: 0.85rem;
}

.crm-detail-list__item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.crm-detail-list__item dt {
  margin: 0;
  font-size: 0.85rem;
  color: var(--crm-text-muted);
  font-weight: 500;
}

.crm-detail-list__item dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.crm-detail-list__item--total dt,
.crm-detail-list__item--total dd {
  font-size: 1.1rem;
  font-weight: 700;
}

.crm-detail-meta {
  display: grid;
  gap: 0.65rem;
}

.crm-detail-meta__item dt {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
}

.crm-detail-meta__item dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--crm-text-secondary);
}

.crm-quote-item-card {
  padding: 0.85rem 0.9rem;
  border-top: 1px solid var(--crm-border);
}

.crm-quote-item-card:first-child {
  border-top: none;
}

.crm-quote-item-card__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 1rem;
}

.crm-quote-item-card__grid dt {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--crm-text-muted);
}

.crm-quote-item-card__grid dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.crm-quote-item-card__total {
  border-top: 1px dashed var(--crm-border);
}

.crm-quote-item-card__note {
  padding: 0.65rem 0.75rem;
  border-radius: var(--crm-radius-xs);
  background-color: var(--crm-surface-alt);
}

.crm-quote-observations {
  font-size: 0.95rem;
  color: var(--crm-text-secondary);
  line-height: 1.55;
}

.crm-quote-observations p:last-child {
  margin-bottom: 0;
}

/* Quote show — denser CRM detail layout */
.quote-show-page {
  padding-bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  .quote-show-page {
    padding-bottom: 0;
  }
}

.quote-show-metrics {
  margin-bottom: 0.85rem;
}

.quote-show-metrics__total .crm-soft-metric__value {
  font-size: 1.2rem;
}

.quote-show-panel {
  margin-bottom: 0;
}

.quote-show-panel__head {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--crm-border);
  background: var(--crm-surface-alt, var(--crm-hover));
}

.quote-show-panel__body {
  padding: 0.85rem;
}

.quote-show-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 1rem;
}

.quote-show-meta-grid__full {
  grid-column: 1 / -1;
}

.quote-show-meta-grid dt {
  margin: 0 0 0.1rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
}

.quote-show-meta-grid dd {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--crm-text-secondary);
}

.quote-show-table-totals td {
  background: var(--crm-surface-alt, var(--crm-hover));
  border-top: 1px solid var(--crm-border);
}

/* Customer show — tabbed detail */
.customer-show-page {
  padding-bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  .customer-show-page {
    padding-bottom: 0;
  }
}

/* Customer show tabs — barra app sticky + chips en móvil/tablet (< 992px),
   underline tabs software Dynamics en desktop (≥ 992px).
   Mismo HTML para web y Turbo Native; colores solo vía --crm-* + color-mix. */
.customer-show-tabs-bar {
  position: sticky;
  top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px));
  z-index: 35;
  margin: 0 -1rem 0.85rem;
  padding: 0.5rem calc(1rem + env(safe-area-inset-right, 0px)) 0.6rem calc(1rem + env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--crm-bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--crm-border);
}

/* En Turbo Native persiste la misma barra móvil web: idéntico offset sticky */
body[data-turbo-native] .customer-show-tabs-bar {
  top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px));
}

.crm-customer-show-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0.1rem 0.15rem 0.15rem;
  border: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.crm-customer-show-tabs::-webkit-scrollbar {
  display: none;
}

.crm-customer-show-tabs .nav-item {
  flex: 0 0 auto;
}

.crm-customer-show-tabs .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--crm-border);
  border-radius: 999px;
  background: var(--crm-surface);
  color: var(--crm-text-secondary);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.1;
  white-space: nowrap;
  scroll-snap-align: start;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.crm-customer-show-tabs .nav-link:hover {
  background: var(--crm-hover);
  color: var(--crm-text);
  border-color: color-mix(in srgb, var(--crm-accent) 40%, var(--crm-border));
}

.crm-customer-show-tabs .nav-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crm-accent) 25%, transparent);
}

.crm-customer-show-tabs .nav-link.active {
  color: var(--crm-text);
  border-color: color-mix(in srgb, var(--crm-accent) 55%, var(--crm-border));
  background: color-mix(in srgb, var(--crm-accent) 12%, var(--crm-surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--crm-accent) 25%, transparent);
}

.customer-tab-icon {
  font-size: 0.85rem;
  color: var(--crm-text-muted);
}

.crm-customer-show-tabs .nav-link.active .customer-tab-icon {
  color: var(--crm-accent);
}

.customer-tab-label {
  white-space: nowrap;
}

.customer-tab-count {
  min-width: 1.35rem;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: var(--crm-border);
  color: var(--crm-text-secondary);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.crm-customer-show-tabs .nav-link.active .customer-tab-count {
  background: color-mix(in srgb, var(--crm-accent) 22%, var(--crm-border));
  color: var(--crm-text);
}

@media (min-width: 992px) {
  .customer-show-tabs-bar {
    top: var(--crm-topbar-height, 48px);
    margin: 0 0 0.85rem;
    padding: 0.15rem 0 0;
    background: color-mix(in srgb, var(--crm-bg) 94%, transparent);
  }

  .crm-customer-show-tabs {
    gap: 0.15rem;
    overflow-x: auto;
    scroll-snap-type: none;
    padding: 0;
  }

  .crm-customer-show-tabs .nav-link {
    min-height: 44px;
    padding: 0.65rem 0.85rem;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--crm-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    scroll-snap-align: none;
  }

  .crm-customer-show-tabs .nav-link:hover {
    color: var(--crm-accent);
    background: transparent;
    border-color: transparent;
  }

  .crm-customer-show-tabs .nav-link.active {
    color: var(--crm-accent);
    background: transparent;
    border-color: transparent transparent var(--crm-accent);
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .crm-customer-show-tabs .nav-link {
    transition: none;
  }
}

/* Panels must not clip Bootstrap dropdowns (contact/delivery menus) */
.customer-show-page .crm-index-panel {
  overflow: visible;
}

.customer-show-page .tab-pane {
  overflow: visible;
}

.customer-show-page .contact-card .dropdown,
.customer-show-page .delivery-address-card .dropdown {
  position: relative;
  z-index: 5;
}

.delivery-address-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.delivery-address-images--compact {
  gap: 0.5rem;
}

.delivery-address-images__item {
  width: 7.5rem;
  padding: 0.5rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background: var(--crm-surface);
  text-align: center;
}

.delivery-address-images__link {
  display: block;
  line-height: 0;
  border-radius: var(--crm-radius-xs);
  overflow: hidden;
  border: 1px solid var(--crm-border);
}

.delivery-address-images__thumb {
  width: 100%;
  max-width: 7.5rem;
  height: 5rem;
  object-fit: cover;
  display: block;
}

.delivery-address-images--compact .delivery-address-images__thumb {
  width: 4.5rem;
  height: 4.5rem;
  max-width: none;
}

.rc-reception-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.rc-reception-images__item {
  width: 7.5rem;
  padding: 0.5rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background: var(--crm-surface);
  text-align: center;
}

.rc-reception-images__link {
  display: block;
  line-height: 0;
  border-radius: var(--crm-radius-xs);
  overflow: hidden;
  border: 1px solid var(--crm-border);
}

.rc-reception-images__thumb {
  width: 100%;
  max-width: 7.5rem;
  height: 5rem;
  object-fit: cover;
  display: block;
}

.rc-reception-images__meta {
  font-size: 0.7rem;
  color: var(--crm-text-muted);
  margin: 0.35rem 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rc-reception-images__delete {
  --bs-btn-font-size: 0.75rem;
}

.customer-show-page .dropdown-menu {
  z-index: 1080;
}

.crm-show-actions-sticky {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1035;
  background-color: var(--crm-surface);
  border-top: 1px solid var(--crm-border);
  box-shadow: 0 -4px 24px rgba(26, 29, 35, 0.1);
  padding: 0.65rem 0.85rem;
  padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  padding-left: calc(0.85rem + env(safe-area-inset-left, 0px));
  padding-right: calc(0.85rem + env(safe-area-inset-right, 0px));
}

.crm-show-actions-sticky__inner {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  max-width: none;
  margin: 0;
}

.crm-show-actions-sticky .btn-action-label {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.crm-show-actions-sticky .btn-action-label:not(.flex-grow-1) {
  flex: 0 0 2.75rem;
  width: 2.75rem;
  padding-inline: 0;
}

[data-bs-theme="dark"] .crm-show-actions-sticky {
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
}

/* ── Turbo Native adjustments ─────────────── */
@supports (-webkit-touch-callout: none) {
  .admin-sidebar {
    overscroll-behavior-y: contain;
  }
  .kanban-board,
  .kanban-hscroll-viewport {
    -webkit-overflow-scrolling: touch;
  }
  .btn,
  .crm-pagination-link,
  .kanban-card,
  .kanban-card-menu,
  .crm-show-actions-sticky .btn-action-label {
    -webkit-tap-highlight-color: transparent;
  }
  .crm-show-actions-sticky {
    backdrop-filter: blur(12px);
    background-color: color-mix(in srgb, var(--crm-surface) 92%, transparent);
  }
}

/* ── Page transition helper ───────────────── */
.turbo-progress-bar {
  background-color: var(--crm-accent) !important;
  height: 3px !important;
}

/* ── Custom font sizes for mobile stat cards ── */
.fs-7 {
  font-size: 0.7rem !important;
}
.fs-md-6 {
  font-size: 0.875rem !important;
}
@media (min-width: 768px) {
  .fs-md-6 {
    font-size: 0.875rem !important;
  }
}

/* ═══════════════════════════════════════════
   Customer form — Input groups with internal buttons
   ═══════════════════════════════════════════ */

/* Ensure input group buttons match the form-control height and radius */
.input-group .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.input-group .form-control:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.input-group .btn {
  border-radius: 0;
  font-weight: 600;
  font-size: 0.85rem;
}
.input-group .btn:first-child {
  border-top-left-radius: var(--crm-radius-sm);
  border-bottom-left-radius: var(--crm-radius-sm);
}
.input-group .btn:last-child {
  border-top-right-radius: var(--crm-radius-sm);
  border-bottom-right-radius: var(--crm-radius-sm);
}
.input-group .btn:not(:last-child) {
  border-right: none;
}

/* Loading spinner inside geolocation button */
[data-geolocation-target="spinner"] .spinner-border-sm {
  width: 0.9rem;
  height: 0.9rem;
  border-width: 0.15em;
}

/* ═══════════════════════════════════════════
   Breadcrumbs — moderno / mobile first
   Aplica a nav[aria-label="breadcrumb"] > ol.breadcrumb
   en todas las vistas (customers, notes, maquila, etc.)
   ═══════════════════════════════════════════ */
.breadcrumb {
  --bs-breadcrumb-divider: "\203A"; /* › */
  --bs-breadcrumb-divider-color: var(--crm-text-muted);
  --bs-breadcrumb-item-padding-x: 0.4rem;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  gap: 0;
  padding: 0.125rem 0;
  font-size: 0.78125rem;
  line-height: 1.3;
}
.breadcrumb::-webkit-scrollbar {
  display: none;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
}
.breadcrumb-item + .breadcrumb-item {
  padding-left: var(--bs-breadcrumb-item-padding-x);
}
.breadcrumb-item + .breadcrumb-item::before {
  align-self: center;
  padding-right: var(--bs-breadcrumb-item-padding-x);
  font-size: 0.9em;
}

.breadcrumb-item a,
.breadcrumb-item.active {
  display: inline-block;
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.breadcrumb-item:last-child a,
.breadcrumb-item.active {
  max-width: 55vw;
}

.breadcrumb-item a {
  padding: 0.15rem 0.3rem;
  margin: -0.15rem -0.3rem;
  border-radius: var(--crm-radius-xs);
  color: var(--crm-accent);
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.breadcrumb-item a:hover,
.breadcrumb-item a:focus-visible {
  background-color: var(--crm-hover);
  color: var(--crm-accent-hover);
  text-decoration: none;
}

.breadcrumb-item.active {
  color: var(--crm-text);
  font-weight: 600;
}

[data-bs-theme="dark"] .breadcrumb-item a {
  color: var(--crm-accent);
}
[data-bs-theme="dark"] .breadcrumb-item a:hover,
[data-bs-theme="dark"] .breadcrumb-item a:focus-visible {
  color: var(--crm-accent-hover);
}
[data-bs-theme="dark"] .breadcrumb-item.active {
  color: var(--crm-text);
}

@media (min-width: 768px) {
  .breadcrumb {
    font-size: 0.8125rem;
  }
  .breadcrumb-item a,
  .breadcrumb-item.active {
    max-width: 20rem;
  }
  .breadcrumb-item:last-child a,
  .breadcrumb-item.active {
    max-width: 28rem;
  }
}

/* ═══════════════════════════════════════════
   Notes — Google Keep style masonry layout
   ═══════════════════════════════════════════ */

/* Color CSS variables for note backgrounds */
:root,
[data-bs-theme="light"] {
  --note-color-default: #ffffff;
  --note-text-default: #1a1d23;
  --note-color-red: #f28b82;
  --note-text-red: #5f1410;
  --note-color-orange: #fbbc04;
  --note-text-orange: #5c3d00;
  --note-color-yellow: #fff475;
  --note-text-yellow: #5c5200;
  --note-color-green: #ccff90;
  --note-text-green: #1b4d00;
  --note-color-blue: #a7ffeb;
  --note-text-blue: #004d3d;
  --note-color-purple: #d7aefb;
  --note-text-purple: #3d005f;
  --note-color-pink: #fdcfe8;
  --note-text-pink: #5c0033;
}

[data-bs-theme="dark"] {
  --note-color-default: #1a1d26;
  --note-text-default: #e4e6ec;
  --note-color-red: #5c2b29;
  --note-text-red: #f58da0;
  --note-color-orange: #614a19;
  --note-text-orange: #f5b840;
  --note-color-yellow: #635d19;
  --note-text-yellow: #f5e840;
  --note-color-green: #345920;
  --note-text-green: #a8f070;
  --note-color-blue: #16504b;
  --note-text-blue: #70f0d0;
  --note-color-purple: #42275e;
  --note-text-purple: #d0a0f0;
  --note-color-pink: #5b2245;
  --note-text-pink: #f0a0d0;
}

/* Note background classes */
.note-bg-default { background-color: var(--note-color-default); color: var(--note-text-default); }
.note-bg-red     { background-color: var(--note-color-red);     color: var(--note-text-red); }
.note-bg-orange  { background-color: var(--note-color-orange);  color: var(--note-text-orange); }
.note-bg-yellow  { background-color: var(--note-color-yellow);  color: var(--note-text-yellow); }
.note-bg-green   { background-color: var(--note-color-green);   color: var(--note-text-green); }
.note-bg-blue    { background-color: var(--note-color-blue);    color: var(--note-text-blue); }
.note-bg-purple  { background-color: var(--note-color-purple);  color: var(--note-text-purple); }
.note-bg-pink    { background-color: var(--note-color-pink);    color: var(--note-text-pink); }

/* Masonry grid for notes */
.notes-masonry {
  column-count: 1;
  column-gap: 1.25rem;
}
@media (min-width: 576px) {
  .notes-masonry { column-count: 2; }
}
@media (min-width: 992px) {
  .notes-masonry { column-count: 3; }
}
@media (min-width: 1200px) {
  .notes-masonry { column-count: 4; }
}

/* Note card styles */
.note-card {
  break-inside: avoid;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  cursor: pointer;
  border-radius: var(--crm-radius-sm);
}
.note-card:hover {
  box-shadow: var(--crm-shadow-md);
  transform: none;
}
.note-card .stretched-link::after {
  z-index: 1;
}
.note-card .dropdown {
  position: relative;
  z-index: 2;
}

/* Note preview text */
.note-preview {
  color: var(--crm-text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Color swatches in form */
.color-swatch {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.color-swatch:hover {
  transform: scale(1.15);
}
.color-swatch.active {
  border-color: var(--crm-text);
  box-shadow: 0 0 0 2px var(--crm-surface), 0 0 0 4px var(--crm-text);
}
.color-swatch-default { background-color: var(--note-color-default); border: 1px solid var(--crm-border); }
.color-swatch-red     { background-color: var(--note-color-red); }
.color-swatch-orange  { background-color: var(--note-color-orange); }
.color-swatch-yellow  { background-color: var(--note-color-yellow); }
.color-swatch-green   { background-color: var(--note-color-green); }
.color-swatch-blue    { background-color: var(--note-color-blue); }
.color-swatch-purple  { background-color: var(--note-color-purple); }
.color-swatch-pink    { background-color: var(--note-color-pink); }

.cursor-pointer {
  cursor: pointer;
}

/* Dark mode note card overrides */
[data-bs-theme="dark"] .note-card {
  box-shadow: var(--crm-shadow);
}

/* Masonry items (wrapper around note cards) keep columns intact */
.notes-masonry > * {
  break-inside: avoid;
}

/* Note card footer / chips */
.note-card__footer {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}
[data-bs-theme="dark"] .note-card__footer {
  border-top-color: rgba(255, 255, 255, 0.12);
}
.note-card__chip {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  background-color: rgba(0, 0, 0, 0.06);
  color: inherit;
}
.note-card__chip--link {
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-bs-theme="dark"] .note-card__chip {
  background-color: rgba(255, 255, 255, 0.12);
}
.note-card__menu {
  color: inherit;
  opacity: 0.55;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}
.note-card__menu:hover,
.note-card__menu:focus-visible {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.08);
}
[data-bs-theme="dark"] .note-card__menu:hover,
[data-bs-theme="dark"] .note-card__menu:focus-visible {
  background-color: rgba(255, 255, 255, 0.14);
}

/* Color filter toolbar (index) — Dynamics command */
.crm-note-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  box-shadow: none;
}
.crm-note-toolbar__label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
}
.crm-note-toolbar__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.crm-note-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--crm-radius-sm);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface-alt);
  color: var(--crm-text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  min-height: 2.25rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.crm-note-chip:hover,
.crm-note-chip:focus-visible {
  color: var(--crm-text);
  border-color: var(--crm-accent);
  transform: none;
}
.crm-note-chip.is-active {
  background: var(--crm-accent);
  border-color: var(--crm-accent);
  color: #fff;
  box-shadow: none;
}
.crm-note-chip__dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
.crm-note-chip.is-active .crm-note-chip__dot {
  border-color: rgba(255, 255, 255, 0.7);
}

/* Note show — full-width detail (mobile-first + Turbo Native) */
.note-show-page {
  width: 100%;
  min-width: 0;
  padding-bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  .note-show-page {
    padding-bottom: 0;
  }
}

.note-show-page .crm-page-header {
  width: 100%;
}

.note-show-page .crm-page-header__title {
  overflow-wrap: anywhere;
}

.note-show-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-surface);
  color: var(--crm-text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
}

.note-show-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
  width: 100%;
  min-width: 0;
}

.note-show-main {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.note-show-main .crm-index-panel {
  margin-bottom: 0;
}

@media (min-width: 992px) {
  .note-show-layout {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
    align-items: start;
    gap: 1rem;
  }
}

.note-show-body {
  min-width: 0;
  margin-bottom: 0;
}

.note-show-body__accent {
  height: 0.35rem;
  width: 100%;
}

.note-show-body__accent.note-bg-default {
  background-color: var(--crm-accent);
}

.note-show-body__content {
  padding: 1rem 0.9rem 1.15rem;
}

@media (min-width: 768px) {
  .note-show-body__content {
    padding: 1.15rem 1.35rem 1.4rem;
  }
}

.note-show-body__trix {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--crm-text);
  max-width: none;
}

.note-show-body__trix .trix-content,
.note-show-body__trix.trix-content {
  max-width: none;
}

.note-show-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  color: var(--crm-text-muted);
  font-size: 0.9rem;
}

.note-show-empty i {
  font-size: 1.1rem;
}

.note-show-aside {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.note-show-aside .crm-index-panel {
  margin-bottom: 0;
}

.note-show-related {
  color: var(--crm-accent);
  text-decoration: none;
  font-weight: 600;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.note-show-related:hover,
.note-show-related:focus-visible {
  text-decoration: underline;
}

.note-show-people {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.note-show-person {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  min-width: 0;
  color: var(--crm-text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
}

.note-show-person--inline {
  min-height: 0;
  display: inline-flex;
}

.note-show-person__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-show-avatar {
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.62rem;
  flex-shrink: 0;
}

/* Note comments — Slack-like thread on show */
.note-comments__body {
  padding: 0.85rem;
}

.note-comments__composer {
  margin-bottom: 0.85rem;
}

.note-comments__restricted,
.note-comments__empty {
  margin: 0 0 0.85rem;
  color: var(--crm-text-muted);
  font-size: 0.88rem;
}

.note-comments__empty[hidden] {
  display: none;
}

.note-comments__list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.note-comment {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.45rem 0.35rem;
  border-radius: var(--crm-radius-sm);
}

.note-comment--reply {
  padding-left: 0.15rem;
}

.note-comment__main {
  min-width: 0;
  flex: 1;
}

.note-comment__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  margin-bottom: 0.15rem;
}

.note-comment__author {
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--crm-text);
}

.note-comment__time {
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

.note-comment__body {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--crm-text);
  overflow-wrap: anywhere;
}

.note-comment__body p {
  margin: 0 0 0.35rem;
}

.note-comment__body p:last-child {
  margin-bottom: 0;
}

.note-comment__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin-top: 0.2rem;
}

.note-comment__action {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.45rem;
  border: 0;
  background: transparent;
  color: var(--crm-text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.note-comment__action:hover,
.note-comment__action:focus-visible {
  color: var(--crm-accent);
}

.note-comment__action--danger:hover,
.note-comment__action--danger:focus-visible {
  color: var(--crm-danger);
}

.note-comment__replies {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.35rem;
  padding-left: 0.65rem;
  border-left: 2px solid var(--crm-border);
}

.note-comment__reply-form {
  margin-top: 0.45rem;
}

.note-comment-form__error {
  margin: 0 0 0.45rem;
  color: var(--crm-danger);
  font-size: 0.82rem;
}

.note-comment-form__row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.note-comment-form__input {
  min-height: 2.75rem;
  resize: vertical;
}

.note-comment-form__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.45rem;
  padding-left: calc(1.75rem + 0.55rem);
}

.note-comment-form__actions .btn {
  min-height: 2.75rem;
}

@media (min-width: 768px) {
  .note-comment__action {
    min-height: 1.75rem;
  }

  .note-comment-form__actions .btn {
    min-height: 2rem;
  }
}

/* Note comment attachments */
.note-comment__attachments {
  margin-top: 0.35rem;
}

.note-comment__images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.note-comment__image {
  display: block;
  border-radius: var(--crm-radius-sm);
  overflow: hidden;
  border: 1px solid var(--crm-border);
  background: var(--crm-surface-alt, #faf9f8);
  line-height: 0;
  flex-shrink: 0;
}

.note-comment__image img {
  width: 5rem;
  height: 5rem;
  object-fit: cover;
  display: block;
}

.note-comment__image:hover,
.note-comment__image:focus-visible {
  border-color: var(--crm-accent);
}

.note-comment__docs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.note-comment__doc {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.35rem;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface-alt, #faf9f8);
  min-height: 2.25rem;
}

.note-comment__doc > i {
  color: var(--crm-text-secondary);
  flex-shrink: 0;
}

.note-comment__doc-name {
  font-size: 0.82rem;
  color: var(--crm-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.note-comment__doc-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 2rem;
  color: var(--crm-text-secondary);
  border-radius: var(--crm-radius-xs);
  text-decoration: none;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.note-comment__doc-download:hover,
.note-comment__doc-download:focus-visible {
  color: var(--crm-accent);
  background: var(--crm-surface-hover, rgba(0, 0, 0, 0.04));
}

/* Note comment form — attach */
.note-comment-form__attach {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
  padding-left: calc(1.75rem + 0.55rem);
}

.note-comment-form__attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2.75rem;
  padding: 0 0.6rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-surface);
  color: var(--crm-text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.note-comment-form__attach-btn:hover,
.note-comment-form__attach-btn:focus-visible {
  border-color: var(--crm-accent);
  color: var(--crm-accent);
}

.note-comment-form__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.note-comment-form__attach-hint {
  font-size: 0.76rem;
  color: var(--crm-text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

@media (min-width: 768px) {
  .note-comment-form__attach-btn {
    min-height: 2rem;
  }

  .note-comment__image img {
    width: 4.5rem;
    height: 4.5rem;
  }
}

/* Note form actions */
.crm-note-form__actions .btn {
  min-height: 2.75rem;
}
@media (max-width: 575.98px) {
  .crm-note-form__actions .btn {
    width: 100%;
  }
}

/* Note share picker — muesca Compartir */
.crm-note-share {
  margin: 0 0 0.85rem;
  border-radius: var(--crm-radius);
}

.crm-note-share__notch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  cursor: pointer;
  user-select: none;
  min-height: 2.25rem;
  padding: 0.2rem 0.7rem 0.2rem 0.55rem;
  border: 1px solid var(--crm-border);
  border-radius: 999px;
  background: var(--crm-surface);
  color: var(--crm-text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.crm-note-share__notch::-webkit-details-marker,
.crm-note-share__notch::marker {
  display: none;
  content: none;
}

.crm-note-share__notch-main {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.crm-note-share__notch-main i {
  font-size: 0.78rem;
  color: var(--crm-accent);
}

.crm-note-share__notch::after {
  content: "";
  width: 0.38rem;
  height: 0.38rem;
  margin-left: 0.1rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.7;
  transition: transform 0.12s ease;
}

.crm-note-share[open] .crm-note-share__notch::after {
  transform: rotate(225deg);
  margin-top: 0.2rem;
}

.crm-note-share__notch:hover,
.crm-note-share__notch:focus-visible {
  color: var(--crm-text);
  border-color: var(--crm-accent);
  background: var(--crm-accent-light);
}

.crm-note-share__notch:focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: 2px;
}

.crm-note-share[open] .crm-note-share__notch,
.crm-note-share.has-selection .crm-note-share__notch {
  border-color: color-mix(in srgb, var(--crm-accent) 55%, var(--crm-border));
  background: var(--crm-accent-light);
  color: var(--crm-accent);
}

.crm-note-share__count:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--crm-accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
}

.crm-note-share__faces:not([hidden]) {
  display: inline-flex;
  align-items: center;
  padding-left: 0.15rem;
}

.crm-note-share__face {
  width: 1.4rem;
  height: 1.4rem;
  margin-left: -0.35rem;
  border-radius: 50%;
  border: 2px solid var(--crm-surface);
  background: color-mix(in srgb, var(--crm-accent) 18%, var(--crm-surface));
  color: var(--crm-accent);
  font-size: 0.52rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.crm-note-share__face:first-child {
  margin-left: 0;
}

.crm-note-share__face--more {
  background: var(--crm-surface-alt);
  color: var(--crm-text-secondary);
  font-size: 0.58rem;
}

.crm-note-share__panel {
  margin-top: 0.5rem;
  padding: 0.7rem;
  background: var(--crm-surface-alt);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
}

.crm-note-share__search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0 0.7rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  color: var(--crm-text-muted);
}

.crm-note-share__search input {
  width: 100%;
  min-height: 2.25rem;
  border: 0;
  background: transparent;
  color: var(--crm-text);
  font-size: 0.82rem;
  outline: none;
}

.crm-note-share__search input::placeholder {
  color: var(--crm-text-muted);
}

.crm-note-share__list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-height: 14.5rem;
  overflow-y: auto;
}

.crm-note-share__user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 44px;
  padding: 0.3rem 0.55rem;
  margin: 0;
  border-radius: var(--crm-radius-sm);
  cursor: pointer;
  color: var(--crm-text);
  font-weight: 500;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.crm-note-share__user:hover {
  background: var(--crm-hover);
}

.crm-note-share__user:focus-within {
  outline: 2px solid var(--crm-accent);
  outline-offset: 1px;
}

.crm-note-share__user:has(.crm-note-share__checkbox:checked) {
  background: var(--crm-accent-light);
}

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

.crm-note-share__avatar {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--crm-accent) 16%, transparent);
  color: var(--crm-accent);
  border: 1px solid color-mix(in srgb, var(--crm-accent) 32%, transparent);
  font-size: 0.62rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.crm-note-share__name {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-note-share__tick {
  margin-left: auto;
  color: var(--crm-accent);
  font-size: 0.72rem;
  opacity: 0;
}

.crm-note-share__user:has(.crm-note-share__checkbox:checked) .crm-note-share__tick {
  opacity: 1;
}

.crm-note-share__empty:not([hidden]),
.crm-note-share__hint {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

.crm-note-share__empty:not([hidden]) {
  padding: 0.35rem 0.55rem;
}

@media (max-width: 575.98px) {
  .crm-note-share__notch {
    min-height: 2.5rem;
  }
}

/* ═══════════════════════════════════════════
   Delivery route — app-style mobile-first UI
   ═══════════════════════════════════════════ */

.delivery-route-app {
  --dr-accent: #0a84ff;
  --dr-accent-soft: rgba(10, 132, 255, 0.1);
  --dr-accent-border: rgba(10, 132, 255, 0.22);
  --dr-success: #34c759;
  --dr-success-soft: rgba(52, 199, 89, 0.12);
  --dr-warning: #ff9500;
  --dr-warning-soft: rgba(255, 149, 0, 0.12);
  --dr-rail: #d1d1d6;
  --dr-metric-bg: #f2f2f7;
  min-height: 60vh;
  padding-bottom: 0.5rem;
}

[data-bs-theme="dark"] .delivery-route-app {
  --dr-accent: #409cff;
  --dr-accent-soft: rgba(64, 156, 255, 0.14);
  --dr-accent-border: rgba(64, 156, 255, 0.28);
  --dr-success: #30d158;
  --dr-success-soft: rgba(48, 209, 88, 0.14);
  --dr-warning: #ff9f0a;
  --dr-warning-soft: rgba(255, 159, 10, 0.14);
  --dr-rail: #48484a;
  --dr-metric-bg: #2c2c2e;
}

.delivery-route-app__header {
  margin-bottom: 1rem;
}

.delivery-route-app__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: var(--dr-metric-bg);
  color: var(--crm-text);
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
  border: 1px solid var(--crm-border);
}

.delivery-route-app__badge i {
  color: var(--dr-accent);
}

/* Hero metrics — iOS/Material-style surface card */
.delivery-route-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--crm-radius);
  margin-bottom: 1rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  box-shadow: var(--crm-shadow);
  color: var(--crm-text);
}

.delivery-route-hero__glow {
  display: none;
}

.delivery-route-hero__content {
  position: relative;
  padding: 1rem 1.05rem 1.05rem;
}

.delivery-route-hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--dr-accent);
  margin-bottom: 0.85rem;
  letter-spacing: 0.01em;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--dr-accent-soft);
}

.delivery-route-hero__metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.delivery-route-hero__metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.65rem 0.35rem;
  border-radius: 12px;
  background: var(--dr-metric-bg);
  border: 1px solid var(--crm-border-light);
}

.delivery-route-hero__metric-value {
  font-size: clamp(1.15rem, 4.5vw, 1.4rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--crm-text);
  font-variant-numeric: tabular-nums;
}

.delivery-route-hero__metric-label {
  font-size: 0.65rem;
  color: var(--crm-text-muted);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.delivery-route-hero__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.delivery-route-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--dr-metric-bg);
  color: var(--crm-text-secondary);
  border: 1px solid var(--crm-border-light);
}

.delivery-route-chip--success {
  background: var(--dr-success-soft);
  color: var(--dr-success);
  border-color: transparent;
}

.delivery-route-chip--warning {
  background: var(--dr-warning-soft);
  color: var(--dr-warning);
  border-color: transparent;
}

.delivery-route-chip--accent {
  background: var(--dr-accent-soft);
  color: var(--dr-accent);
  border-color: transparent;
}

.delivery-route-hero__note {
  font-size: 0.72rem;
  color: var(--crm-text-muted);
  line-height: 1.45;
  margin: 0 0 0.75rem;
}

/* Origin card */
.delivery-route-origin {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  box-shadow: var(--crm-shadow);
}

.delivery-route-origin__icon {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--dr-metric-bg);
  color: var(--dr-accent);
  font-size: 1.1rem;
  border: 1px solid var(--crm-border-light);
}

.delivery-route-origin__body {
  flex: 1;
  min-width: 0;
}

.delivery-route-origin__label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
  margin-bottom: 0.2rem;
}

.delivery-route-origin__title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.35rem;
  color: var(--crm-text);
}

.delivery-route-origin__address {
  font-size: 0.82rem;
  color: var(--crm-text-secondary);
  margin-bottom: 0.45rem;
  line-height: 1.4;
}

.delivery-route-origin__status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
}

.delivery-route-origin__status--ok {
  background: var(--dr-success-soft);
  color: var(--dr-success);
}

.delivery-route-origin__status--warn {
  background: var(--dr-warning-soft);
  color: var(--dr-warning);
}

.delivery-route-origin__link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.delivery-route-origin__map-btn {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--crm-border);
  background: var(--dr-metric-bg);
  color: var(--dr-accent);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.delivery-route-origin__map-btn:hover,
.delivery-route-origin__map-btn:focus-visible {
  background: var(--dr-accent-soft);
  border-color: var(--dr-accent-border);
  color: var(--dr-accent);
}

/* Alert */
.delivery-route-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  border-radius: 12px;
  background: var(--dr-warning-soft);
  border: 1px solid rgba(255, 149, 0, 0.22);
  color: var(--crm-text);
  font-size: 0.82rem;
  line-height: 1.45;
}

.delivery-route-alert i {
  color: var(--dr-warning);
  margin-top: 0.1rem;
  flex-shrink: 0;
}

/* Timeline */
.delivery-route-timeline {
  margin-bottom: 1rem;
}

.delivery-route-timeline__header {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.75rem;
}

.delivery-route-timeline__title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: var(--crm-text);
}

.delivery-route-timeline__hint {
  font-size: 0.78rem;
  color: var(--crm-text-muted);
  margin: 0;
}

.delivery-route-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 80px;
}

.delivery-route-list.drag-over {
  background: var(--dr-accent-soft);
  border-radius: var(--crm-radius-sm);
}

/* Stop item */
.delivery-route-item {
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  gap: 0.65rem;
  cursor: grab;
  touch-action: manipulation;
  transition: opacity 0.25s ease;
}

.delivery-route-item:hover .delivery-route-item__card {
  border-color: var(--dr-accent-border);
  box-shadow: var(--crm-shadow);
}

.delivery-route-item.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.delivery-route-item.dragging .delivery-route-item__card {
  transform: scale(0.98);
}

.delivery-route-item--removed {
  opacity: 0;
  transform: translateX(100%);
}

.delivery-route-item__rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 0.35rem;
}

.delivery-route-item__dot {
  flex-shrink: 0;
}

.delivery-route-item__connector {
  flex: 1;
  width: 2px;
  min-height: 1rem;
  margin: 0.25rem 0;
  background: var(--dr-rail);
  border-radius: 2px;
}

.delivery-route-stop-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  background: var(--dr-accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  border: none;
  box-shadow: 0 2px 6px rgba(10, 132, 255, 0.28);
}

.delivery-route-item__card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.9rem;
  margin-bottom: 0.65rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  box-shadow: var(--crm-shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.delivery-route-item--last .delivery-route-item__card {
  margin-bottom: 0;
}

.delivery-route-item-main {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.delivery-route-item-body {
  flex: 1;
  min-width: 0;
}

.delivery-route-item-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.delivery-route-item-title {
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 700;
  color: var(--crm-text);
}

.delivery-route-gps-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.delivery-route-gps-badge--ok {
  background: var(--dr-success-soft);
  color: var(--dr-success);
}

.delivery-route-gps-badge--warn {
  background: var(--dr-warning-soft);
  color: var(--dr-warning);
}

.delivery-route-item-customer {
  font-size: 0.88rem;
  color: var(--crm-text-secondary);
  font-weight: 500;
}

.delivery-route-address {
  font-size: 0.82rem;
  color: var(--crm-text-secondary);
  line-height: 1.4;
}

.delivery-route-distance {
  font-size: 0.76rem;
  color: var(--dr-accent);
  font-weight: 600;
}

.delivery-route-distance--muted {
  color: var(--crm-text-muted);
  font-weight: 500;
}

.delivery-route-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.delivery-route-tag {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--crm-text-secondary);
  background: var(--dr-metric-bg);
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--crm-border-light);
}

.delivery-route-item-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.delivery-route-btn-delivered {
  background-color: var(--crm-success);
  border-color: var(--crm-success);
}

.delivery-route-btn-delivered:hover,
.delivery-route-btn-delivered:focus-visible {
  background-color: var(--crm-success-hover);
  border-color: var(--crm-success-hover);
}

[data-bs-theme="dark"] .delivery-route-stop-number {
  box-shadow: 0 2px 8px rgba(64, 156, 255, 0.35);
}

.delivery-route-btn-delivered,
.delivery-route-btn-map,
.delivery-route-btn-not-delivered {
  min-height: 44px;
  font-weight: 600;
  font-size: 0.84rem;
  border-radius: var(--crm-radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.delivery-route-btn-not-delivered {
  grid-column: 1 / -1;
  color: var(--crm-warning);
  border-color: color-mix(in srgb, var(--crm-warning) 40%, var(--crm-border));
  background-color: color-mix(in srgb, var(--crm-warning) 8%, transparent);
}

.delivery-route-btn-not-delivered:hover,
.delivery-route-btn-not-delivered:focus-visible {
  color: var(--crm-warning-hover);
  background-color: color-mix(in srgb, var(--crm-warning) 14%, transparent);
  border-color: color-mix(in srgb, var(--crm-warning) 55%, var(--crm-border));
}

.delivery-route-failure-note {
  padding: 0.55rem 0.7rem;
  border-radius: var(--crm-radius-sm);
  background: color-mix(in srgb, var(--crm-warning) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--crm-warning) 30%, var(--crm-border));
}

.delivery-route-failure-note__title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--crm-warning);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.delivery-route-failure-note__when {
  font-weight: 500;
  color: var(--crm-text-muted);
}

.delivery-route-failure-note__reason {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--crm-text);
}

.delivery-route-failure-note__observations {
  font-size: 0.8rem;
  color: var(--crm-text-secondary);
  line-height: 1.4;
}

.delivery-route-reorder {
  display: flex;
  gap: 0.45rem;
  grid-column: 1 / -1;
}

.delivery-route-btn-move {
  flex: 1;
  min-height: 40px;
  border-radius: var(--crm-radius-sm);
  touch-action: manipulation;
}

/* Secondary actions */
.delivery-route-secondary-actions {
  margin-bottom: 1rem;
}

/* Sticky dock */
.delivery-route-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1035;
  background-color: color-mix(in srgb, var(--crm-surface) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--crm-border);
  box-shadow: 0 -4px 24px rgba(26, 29, 35, 0.1);
  padding: 0.65rem 0.85rem;
  padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  padding-left: calc(0.85rem + env(safe-area-inset-left, 0px));
  padding-right: calc(0.85rem + env(safe-area-inset-right, 0px));
}

.delivery-route-dock__inner {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  max-width: none;
  margin: 0;
}

.delivery-route-dock__btn {
  flex: 1;
  min-height: 48px;
  font-weight: 700;
  border-radius: var(--crm-radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.delivery-route-dock__btn--primary {
  flex: 1.35;
  background-color: var(--crm-success);
  border-color: var(--crm-success);
}

.delivery-route-dock__btn--primary:hover,
.delivery-route-dock__btn--primary:focus-visible {
  background-color: var(--crm-success-hover);
  border-color: var(--crm-success-hover);
}

.delivery-route-dock .btn-primary {
  background-color: var(--crm-accent);
  border-color: var(--crm-accent);
}

.delivery-route-dock .btn-primary:hover,
.delivery-route-dock .btn-primary:focus-visible {
  background-color: var(--crm-accent-hover);
  border-color: var(--crm-accent-hover);
}

.delivery-route-dock__btn.is-loading {
  pointer-events: none;
  opacity: 0.75;
}

.delivery-route-dock-spacer {
  height: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

[data-bs-theme="dark"] .delivery-route-dock {
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
}

/* Empty state */
.delivery-route-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.5rem 1.25rem;
  background: var(--crm-surface);
  border: 2px dashed var(--crm-border);
  border-radius: var(--crm-radius);
}

.delivery-route-empty__icon {
  width: 4.5rem;
  height: 4.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--dr-metric-bg);
  color: var(--crm-text-muted);
  font-size: 2rem;
  margin-bottom: 1rem;
  border: 1px solid var(--crm-border-light);
}

.delivery-route-empty__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--crm-text);
}

.delivery-route-empty__text {
  font-size: 0.88rem;
  color: var(--crm-text-muted);
  max-width: 28rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

@media (min-width: 768px) {
  .delivery-route-app__header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .delivery-route-hero__content {
    padding: 1.25rem 1.5rem 1.35rem;
  }

  .delivery-route-item {
    grid-template-columns: 2.75rem 1fr;
    gap: 0.85rem;
  }

  .delivery-route-item__card {
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    padding: 1rem 1.15rem;
  }

  .delivery-route-item-main {
    flex: 1;
  }

  .delivery-route-item-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 148px;
    grid-template-columns: none;
  }

  .delivery-route-reorder {
    grid-column: auto;
  }
}

@media (min-width: 992px) {
  .delivery-route-item-actions {
    flex-direction: row;
    align-items: center;
    min-width: auto;
    gap: 0.45rem;
  }

  .delivery-route-reorder {
    flex-direction: column;
    width: auto;
  }

  .delivery-route-btn-move {
    width: 40px;
    flex: 0 0 auto;
  }

  .delivery-route-dock__inner {
    max-width: 480px;
    margin-inline: auto;
  }
}

/* Delivery proof modal + signature pad */
.delivery-proof-modal__dialog {
  max-width: 440px;
  margin: 1rem auto;
}

.delivery-proof-modal__content {
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  background: var(--crm-surface);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}

.delivery-proof-modal__eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
  margin: 0;
}

.delivery-proof-modal__title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--crm-text);
  margin: 0;
}

.delivery-proof-modal__hint {
  font-size: 0.85rem;
  color: var(--crm-text-muted);
  line-height: 1.45;
}

.delivery-proof-modal__label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--crm-text-secondary);
}

.delivery-proof-modal__optional {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--crm-text-muted);
}

.delivery-proof-modal__clear {
  min-height: 36px;
  font-size: 0.78rem;
}

.delivery-proof-modal__pad {
  position: relative;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--crm-surface-alt) 70%, transparent), var(--crm-surface));
  overflow: hidden;
  touch-action: none;
}

.delivery-proof-modal__canvas {
  display: block;
  width: 100%;
  height: 160px;
  cursor: crosshair;
  touch-action: none;
}

.delivery-proof-modal__pad-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  pointer-events: none;
  color: var(--crm-text-muted);
  font-size: 0.85rem;
}

.delivery-proof-modal__pad-hint[hidden] {
  display: none !important;
}

/* Delivery failure modal */
.delivery-failure-modal__dialog {
  max-width: 440px;
  margin: 1rem auto;
}

.delivery-failure-modal__content {
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  background: var(--crm-surface);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}

.delivery-failure-modal__eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--crm-warning);
  margin: 0;
}

.delivery-failure-modal__title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--crm-text);
  margin: 0;
}

.delivery-failure-modal__hint {
  font-size: 0.85rem;
  color: var(--crm-text-muted);
  line-height: 1.45;
}

.delivery-failure-modal__label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--crm-text-secondary);
}

.delivery-failure-modal__required {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--crm-danger);
}

.delivery-failure-modal__optional {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--crm-text-muted);
}

/* ── Firma del cliente (Recepción) en Repair Cycles ─────────────── */
.rc-signature-section__hint {
  font-size: 0.85rem;
  color: var(--crm-text-muted);
  line-height: 1.45;
  margin-bottom: 0.75rem;
}

.rc-signature-pad-wrap {
  border-top: 1px solid var(--crm-border);
  padding-top: 0.5rem;
}

.rc-signature-pad {
  position: relative;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--crm-surface-alt) 70%, transparent), var(--crm-surface));
  overflow: hidden;
  touch-action: none;
}

.rc-signature-canvas {
  display: block;
  width: 100%;
  height: 180px;
  cursor: crosshair;
  touch-action: none;
}

.rc-signature-pad-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  pointer-events: none;
  color: var(--crm-text-muted);
  font-size: 0.85rem;
}

.rc-signature-pad-hint[hidden] {
  display: none !important;
}

.rc-signature-clear {
  min-height: 36px;
  font-size: 0.78rem;
}

.rc-signature-preview {
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background: color-mix(in srgb, var(--crm-surface-alt) 50%, var(--crm-surface));
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.rc-signature-preview__label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
  margin: 0 0 0.5rem;
}

.rc-signature-preview__link {
  display: block;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background: var(--crm-surface);
  overflow: hidden;
}

.rc-signature-preview__img {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  background: var(--crm-surface);
}

[data-bs-theme="dark"] .rc-signature-preview__img {
  filter: invert(1) hue-rotate(180deg);
}

.rc-signature-preview__replace {
  margin-top: 0.5rem;
  min-height: 34px;
  font-size: 0.78rem;
}

.kanban-card-delivery {
  margin-top: 0.35rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background: color-mix(in srgb, var(--crm-success, #166534) 8%, var(--crm-surface));
}

.kanban-card-delivery__label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--crm-text-secondary);
}

.kanban-card-delivery__when {
  margin-left: auto;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--crm-text-muted);
}

.kanban-card-delivery__receiver {
  font-size: 0.75rem;
  color: var(--crm-text);
  margin: 0;
}

.kanban-card-delivery__signature {
  display: block;
  margin-top: 0.35rem;
  border: 1px solid var(--crm-border);
  border-radius: 4px;
  background: #fff;
  overflow: hidden;
  max-width: 100%;
}

.kanban-card-delivery__signature-img {
  display: block;
  width: 100%;
  max-height: 64px;
  object-fit: contain;
  background: #fff;
}

[data-bs-theme="dark"] .kanban-card-delivery__signature,
[data-bs-theme="dark"] .kanban-card-delivery__signature-img {
  background: #f8fafc;
}

/* ═══════════════════════════════════════════
   Customers index — mobile-first modern list
   ═══════════════════════════════════════════ */

/* Page header — Dynamics dense */
.crm-page-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}
.crm-page-header__title {
  font-size: clamp(1.15rem, 3.5vw, 1.35rem);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.25;
  color: var(--crm-text);
  margin: 0;
}
.crm-page-header__subtitle {
  font-size: 0.8125rem;
  color: var(--crm-text-secondary);
  margin: 0;
}
.crm-page-header__actions {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}
.crm-page-header__actions .btn {
  flex: 1 1 auto;
  min-height: 2.75rem;
}

/* Filter bar */
.crm-filter-bar {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0;
}
.crm-filter-bar__search {
  position: relative;
}
.crm-filter-bar__search .form-control {
  padding-left: 2.5rem;
}
.crm-filter-bar__search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--crm-text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}
.crm-filter-bar__actions {
  display: flex;
  gap: 0.5rem;
}
.crm-filter-bar__actions .btn {
  min-height: 2.75rem;
  flex: 1 1 auto;
}

/* Customer cards (mobile) */
.crm-customer-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  box-shadow: var(--crm-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.crm-customer-card:hover {
  box-shadow: var(--crm-shadow-md);
  border-color: color-mix(in srgb, var(--crm-accent) 30%, var(--crm-border));
}
.crm-customer-card__header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.crm-customer-card__avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.crm-customer-card__info {
  flex: 1;
  min-width: 0;
}
.crm-customer-card__name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--crm-text);
  line-height: 1.3;
}
.crm-customer-card__legal {
  font-size: 0.8rem;
  color: var(--crm-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-customer-card__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
}
.crm-customer-card__meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.crm-customer-card__meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
}
.crm-customer-card__meta-value {
  color: var(--crm-text);
  font-weight: 500;
}
.crm-customer-card__address {
  font-size: 0.8rem;
  color: var(--crm-text-secondary);
  line-height: 1.4;
}
.crm-customer-card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--crm-border-light);
}
.crm-customer-card__actions .btn {
  min-height: 2.75rem;
}
.crm-customer-card__actions .btn-danger-wide {
  grid-column: 1 / -1;
}

/* Results count */
.crm-results-count {
  font-size: 0.85rem;
  color: var(--crm-text-secondary);
  margin-bottom: 0.75rem;
  font-weight: 500;
}

/* Empty state tweaks */
.crm-empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}
.crm-empty-state i {
  font-size: 3.5rem;
  color: var(--crm-text-muted);
  opacity: 0.35;
}
.crm-empty-state h5 {
  font-weight: 700;
  color: var(--crm-text-secondary);
  margin-top: 1.25rem;
}
.crm-empty-state p {
  color: var(--crm-text-muted);
  font-size: 0.95rem;
}
.crm-empty-state__actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
  margin: 1.25rem auto 0;
}

/* FAB for mobile — flat */
.crm-fab {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: 1040;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-image: none;
  box-shadow: none;
}
.crm-fab:hover,
.crm-fab:focus-visible {
  transform: none;
  box-shadow: none;
}
.crm-fab:active {
  transform: none;
  filter: brightness(0.94);
}

/* Responsive filter bar and header */
@media (min-width: 768px) {
  .crm-page-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
  }
  .crm-page-header__actions {
    width: auto;
  }
  .crm-page-header__actions .btn {
    flex: 0 0 auto;
  }
  .crm-filter-bar {
    grid-template-columns: 2fr 1fr 1fr auto auto;
    align-items: end;
  }
  .crm-filter-bar__actions {
    flex-direction: row;
  }
  .crm-filter-bar__actions .btn {
    flex: 0 0 auto;
  }
  .crm-customer-card__actions {
    grid-template-columns: repeat(3, 1fr);
  }
  .crm-customer-card__actions .btn-danger-wide {
    grid-column: auto;
  }
  .crm-empty-state__actions {
    flex-direction: row;
    justify-content: center;
    max-width: none;
  }
}

@media (min-width: 992px) {
  .crm-filter-bar {
    grid-template-columns: 2.5fr 1fr 1fr auto auto;
  }
}

/* ═══════════════════════════════════════════
   Products index — mobile-first modern list
   ═══════════════════════════════════════════ */

.crm-product-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  box-shadow: var(--crm-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.crm-product-card:hover {
  box-shadow: var(--crm-shadow-md);
  border-color: color-mix(in srgb, var(--crm-accent) 30%, var(--crm-border));
}
.crm-product-card__header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.crm-product-card__avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--crm-radius-sm);
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.crm-product-card__info {
  flex: 1;
  min-width: 0;
}
.crm-product-card__name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--crm-text);
  line-height: 1.3;
}
.crm-product-card__key {
  font-size: 0.8rem;
  color: var(--crm-text-secondary);
  font-family: var(--bs-font-monospace, monospace);
}
.crm-product-card__price-tag {
  text-align: right;
  flex-shrink: 0;
}
.crm-product-card__price-tag .label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
}
.crm-product-card__price-tag .value {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--crm-accent);
  line-height: 1.2;
}
.crm-product-card__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
}
.crm-product-card__meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.crm-product-card__meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
}
.crm-product-card__meta-value {
  color: var(--crm-text);
  font-weight: 500;
}
.crm-product-card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--crm-border-light);
}
.crm-product-card__actions .btn {
  min-height: 2.75rem;
}
.crm-product-card__actions .btn-danger-wide {
  grid-column: 1 / -1;
}

@media (min-width: 768px) {
  .crm-product-card__actions {
    grid-template-columns: repeat(3, 1fr);
  }
  .crm-product-card__actions .btn-danger-wide {
    grid-column: auto;
  }
}

/* ═══════════════════════════════════════════
   Data grid — compact software-style records table
   ═══════════════════════════════════════════ */

.crm-data-table {
  margin-bottom: 0;
  font-size: 0.8125rem;
}
.crm-data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--crm-surface-alt);
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.1;
  color: var(--crm-text-secondary);
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--crm-border);
  white-space: nowrap;
}
.crm-data-table tbody td {
  padding: 0.35rem 0.75rem;
  line-height: 1.3;
  vertical-align: middle;
  border-top: 1px solid var(--crm-border-light);
  color: var(--crm-text);
}
.crm-data-table tbody tr:first-child td {
  border-top: 0;
}
.crm-data-table tbody tr:nth-child(even) {
  background-color: color-mix(in srgb, var(--crm-hover) 45%, transparent);
}
.crm-data-table.table-hover tbody tr:hover {
  background-color: var(--crm-hover);
}
/* Desktop-software style action toolbar within the grid */
.crm-data-table .btn-actions {
  gap: 0.25rem;
  justify-content: flex-end;
}
.crm-data-table .btn-action {
  --btn-action-size: 2rem;
  width: var(--btn-action-size);
  height: var(--btn-action-size);
  border: 1px solid transparent;
  border-radius: var(--crm-radius-xs);
  background-color: transparent;
  color: var(--crm-text-muted);
  font-size: 0.875rem;
  box-shadow: none;
}
.crm-data-table .btn-action.btn-action-view {
  color: var(--crm-text-muted);
  background-color: transparent;
}
.crm-data-table .btn-action.btn-action-edit {
  color: var(--crm-text-muted);
  background-color: transparent;
}
.crm-data-table .btn-action.btn-action-delete {
  color: var(--crm-text-muted);
  background-color: transparent;
}
.crm-data-table .btn-action:hover,
.crm-data-table .btn-action:focus-visible {
  transform: none;
  box-shadow: none;
}
.crm-data-table .btn-action.btn-action-view:hover,
.crm-data-table .btn-action.btn-action-view:focus-visible {
  color: var(--crm-text);
  background-color: var(--crm-hover);
  border-color: var(--crm-border-light);
}
.crm-data-table .btn-action.btn-action-edit {
  color: var(--crm-text-muted);
  background-color: transparent;
}
.crm-data-table .btn-action.btn-action-edit:hover,
.crm-data-table .btn-action.btn-action-edit:focus-visible {
  color: var(--crm-accent);
  background-color: var(--crm-accent-light);
  border-color: transparent;
}
.crm-data-table .btn-action.btn-action-delete {
  color: var(--crm-text-muted);
  background-color: transparent;
}
.crm-data-table .btn-action.btn-action-delete:hover,
.crm-data-table .btn-action.btn-action-delete:focus-visible {
  color: var(--crm-danger);
  background-color: color-mix(in srgb, var(--crm-danger) 10%, transparent);
  border-color: transparent;
}
[data-bs-theme="dark"] .crm-data-table .btn-action {
  background-color: transparent;
}
[data-bs-theme="dark"] .crm-data-table .btn-action.btn-action-delete:hover,
[data-bs-theme="dark"] .crm-data-table .btn-action.btn-action-delete:focus-visible {
  color: var(--crm-danger);
  background-color: color-mix(in srgb, var(--crm-danger) 15%, transparent);
}

/* Clickable clave/folio link inside data grids (light + dark) */
.crm-link-folio {
  color: var(--crm-text);
  text-decoration: none;
  border-radius: var(--crm-radius-xs);
  transition: color 120ms ease, text-decoration-color 120ms ease;
}
.crm-link-folio:hover {
  color: var(--crm-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.crm-link-folio:focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: 1px;
  color: var(--crm-accent);
}

/* ═══════════════════════════════════════════
   Customers index — mobile app list + desktop software grid
   ═══════════════════════════════════════════ */

.crm-customers-index {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

.crm-customers-filters {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  padding: 0.75rem;
}

.crm-customers-filters__form {
  margin: 0;
}

.crm-customers-filters__label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
  margin-bottom: 0.3rem;
}

.crm-customers-filters .form-control,
.crm-customers-filters .form-select {
  min-height: 2.75rem;
  font-size: 0.9375rem;
}

.crm-customers-filters .crm-filter-bar__search {
  display: flex;
  flex-direction: column;
}

.crm-customers-filters .crm-filter-bar__search-icon {
  top: auto;
  bottom: 0.9rem;
  transform: none;
}

.crm-customers-index .crm-results-count {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
}

.crm-customers-panel {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  overflow: hidden;
}

.crm-customers-panel__footer {
  padding: 0.75rem 0.85rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--crm-border-light);
  background: var(--crm-surface-alt);
}

/* Mobile app-style list rows (canónico clientes + genérico reutilizable) */
.crm-customers-list,
.crm-app-list {
  display: flex;
  flex-direction: column;
}

.crm-index-panel {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  overflow: hidden;
  margin-bottom: 1rem;
}
.crm-index-panel__table-wrap {
  max-height: calc(100vh - 16rem);
  overflow: auto;
}

@media (max-width: 767.98px) {
  .crm-index-panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    margin-left: -1rem;
    margin-right: -1rem;
  }
}
.crm-soft-metrics {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 1rem;
  padding-bottom: 0.15rem;
}
.crm-soft-metrics::-webkit-scrollbar { display: none; }
.crm-soft-metric {
  flex: 0 0 auto;
  min-width: 7.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
}
.crm-soft-metric__label {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
  margin-bottom: 0.15rem;
}
.crm-soft-metric__value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--crm-text);
  letter-spacing: 0;
  line-height: 1.2;
}
.crm-soft-metric__hint {
  font-size: 0.7rem;
  color: var(--crm-text-muted);
  margin-top: 0.15rem;
}
@media (min-width: 768px) {
  .crm-soft-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: visible;
    gap: 0.65rem;
  }
  .crm-soft-metric { min-width: 0; }
}

.crm-dashboard-metrics.crm-soft-metrics {
  margin-bottom: 0.75rem;
}

@media (min-width: 768px) {
  .crm-dashboard-metrics.crm-soft-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .crm-dashboard-metrics.crm-soft-metrics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.crm-dashboard-pipeline.crm-soft-metrics {
  margin-bottom: 1rem;
}

.crm-soft-metric--alert {
  border-color: color-mix(in srgb, var(--crm-danger, #b91c1c) 45%, var(--crm-border));
  background: color-mix(in srgb, var(--crm-danger, #b91c1c) 8%, var(--crm-surface));
}

.crm-soft-metric--warn,
.crm-soft-metric--bottleneck {
  border-color: color-mix(in srgb, var(--crm-bottleneck) 45%, var(--crm-border));
  background: var(--crm-bottleneck-bg);
}

.crm-soft-metric--alert .crm-soft-metric__value {
  color: var(--crm-danger, #b91c1c);
}

.crm-soft-metric--warn .crm-soft-metric__value,
.crm-soft-metric--bottleneck .crm-soft-metric__value {
  color: var(--crm-bottleneck);
}

.crm-soft-metric--success {
  border-color: color-mix(in srgb, var(--crm-success) 45%, var(--crm-border));
  background: var(--crm-success-bg);
}

.crm-soft-metric--success .crm-soft-metric__value {
  color: var(--crm-success);
}

/* KPI con icono lead */
.crm-soft-metric__label .fa-solid,
.crm-soft-metric__label .fa-regular {
  margin-right: 0.3rem;
  font-size: 0.7rem;
  color: var(--crm-text-muted);
  width: 0.85rem;
  text-align: center;
}

.crm-soft-metric--success .crm-soft-metric__label .fa-solid,
.crm-soft-metric--success .crm-soft-metric__label .fa-regular {
  color: var(--crm-success);
}

.crm-soft-metric--alert .crm-soft-metric__label .fa-solid,
.crm-soft-metric--alert .crm-soft-metric__label .fa-regular {
  color: var(--crm-danger, #b91c1c);
}

.crm-soft-metric--warn .crm-soft-metric__label .fa-solid,
.crm-soft-metric--warn .crm-soft-metric__label .fa-regular,
.crm-soft-metric--bottleneck .crm-soft-metric__label .fa-solid,
.crm-soft-metric--bottleneck .crm-soft-metric__label .fa-regular {
  color: var(--crm-bottleneck);
}

/* ── Dashboard M365 (mobile-first, Fluent) ─────────────────────────── */
.crm-dash-header__date {
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

/* MessageBar estilo M365 para alertas operativas */
.crm-dash-alert {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  margin-bottom: 0.75rem;
  background: color-mix(in srgb, var(--crm-danger) 9%, var(--crm-surface));
  border: 1px solid color-mix(in srgb, var(--crm-danger) 38%, var(--crm-border));
  border-left: 3px solid var(--crm-danger);
  border-radius: var(--crm-radius-sm);
  color: var(--crm-text);
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.crm-dash-alert:hover {
  background: color-mix(in srgb, var(--crm-danger) 14%, var(--crm-surface));
  color: var(--crm-text);
}
.crm-dash-alert > .fa-solid:first-child {
  color: var(--crm-danger);
  font-size: 1rem;
  flex-shrink: 0;
}
.crm-dash-alert__text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.82rem;
  line-height: 1.3;
}
.crm-dash-alert__chevron {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

/* KPIs clicables (misma tira .crm-soft-metrics, ahora enlaces) */
a.crm-soft-metric.crm-dash-kpi {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 44px;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
a.crm-soft-metric.crm-dash-kpi:hover {
  border-color: color-mix(in srgb, var(--crm-accent) 50%, var(--crm-border));
}
a.crm-soft-metric.crm-dash-kpi:hover .crm-soft-metric__value {
  color: var(--crm-accent);
}
a.crm-soft-metric.crm-dash-kpi:hover .crm-soft-metric__label .fa-solid,
a.crm-soft-metric.crm-dash-kpi:hover .crm-soft-metric__label .fa-regular {
  color: var(--crm-accent);
}
a.crm-soft-metric.crm-dash-kpi:focus-visible,
.crm-dash-alert:focus-visible,
.crm-dash-quick__item:focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: 2px;
}

/* Snap-scroll en la tira de KPIs solo en móvil */
@media (max-width: 767.98px) {
  .crm-dash-kpis {
    scroll-snap-type: x proximity;
  }
  .crm-dash-kpis > .crm-dash-kpi {
    scroll-snap-align: start;
  }
}
@media (prefers-reduced-motion: reduce) {
  .crm-dash-kpis {
    scroll-snap-type: none;
  }
}

/* Accesos rápidos estilo lanzador M365 (solo móvil; desktop usa el header) */
.crm-dash-quick {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}
.crm-dash-quick__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 64px;
  padding: 0.6rem 0.25rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  color: var(--crm-text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.crm-dash-quick__item > .fa-solid {
  font-size: 1.1rem;
  color: var(--crm-accent);
}
.crm-dash-quick__item:hover {
  border-color: color-mix(in srgb, var(--crm-accent) 50%, var(--crm-border));
  background: var(--crm-accent-light);
  color: var(--crm-text);
}
.crm-dash-quick__item:active {
  background: var(--crm-hover);
}

/* Contenedor de gráfica con altura fija (evita saltos de layout) */
.crm-dash-chart {
  position: relative;
  height: 220px;
}
@media (min-width: 768px) {
  .crm-dash-chart {
    height: 240px;
  }
}

/* Pintura diferida de paneles bajo el pliegue */
.crm-dash-panel {
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
}

/* ── Dashboard v2 (app sobria, jerarquía por tamaño) ─────────────────
   Mismos datos que v1; solo tokens --crm-*. Sin gradientes ni glow.
   Móvil: rejillas fijas tipo app (sin scroll oculto). Desktop: grid. */
.crm-dash2-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}
.crm-dash2-head__title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--crm-text);
  margin: 0;
}
.crm-dash2-head__date {
  font-size: 0.78rem;
  color: var(--crm-text-muted);
  margin: 0.1rem 0 0;
}
.crm-dash2-head__actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* KPIs héroes: cifra grande tabular, tile neutro, chevron sutil */
.crm-dash2-heroes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
@media (min-width: 768px) {
  .crm-dash2-heroes {
    gap: 0.65rem;
    margin-bottom: 0.65rem;
  }
}
.crm-dash2-hero {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 92px;
  padding: 0.75rem 0.8rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  text-decoration: none;
  color: var(--crm-text);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.crm-dash2-hero:hover {
  border-color: color-mix(in srgb, var(--crm-accent) 50%, var(--crm-border));
  color: var(--crm-text);
}
.crm-dash2-hero__tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  flex-shrink: 0;
  background: var(--crm-surface-alt);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  color: var(--crm-accent);
  font-size: 1rem;
}
.crm-dash2-hero--risk .crm-dash2-hero__tile {
  color: var(--crm-danger);
  border-color: color-mix(in srgb, var(--crm-danger) 40%, var(--crm-border));
  background: color-mix(in srgb, var(--crm-danger) 9%, var(--crm-surface));
}
.crm-dash2-hero__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
.crm-dash2-hero__label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--crm-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-dash2-hero__value {
  font-size: clamp(1.12rem, 4.5vw, 1.45rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 380px) {
  .crm-dash2-hero {
    gap: 0.55rem;
    padding: 0.65rem 0.6rem;
  }
  .crm-dash2-hero__tile {
    width: 2rem;
    height: 2rem;
    font-size: 0.85rem;
  }
}
.crm-dash2-hero__hint {
  font-size: 0.72rem;
  color: var(--crm-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-dash2-hero__risk {
  color: var(--crm-danger);
  font-weight: 600;
}
.crm-dash2-hero__chev {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--crm-text-muted);
}

/* KPIs secundarios compactos */
.crm-dash2-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}
@media (min-width: 768px) {
  .crm-dash2-kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
  }
}
.crm-dash2-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-height: 44px;
  padding: 0.6rem 0.7rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  text-decoration: none;
  color: var(--crm-text);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.crm-dash2-kpi:hover {
  border-color: color-mix(in srgb, var(--crm-accent) 50%, var(--crm-border));
  color: var(--crm-text);
}
.crm-dash2-kpi__top {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}
.crm-dash2-kpi__tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
  background: var(--crm-surface-alt);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  color: var(--crm-accent);
  font-size: 0.72rem;
}
.crm-dash2-kpi__label {
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--crm-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-dash2-kpi__value {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-dash2-kpi__hint {
  font-size: 0.7rem;
  color: var(--crm-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-dash2-kpi--risk .crm-dash2-kpi__value {
  color: var(--crm-danger);
}
.crm-dash2-kpi--risk .crm-dash2-kpi__tile {
  color: var(--crm-danger);
  border-color: color-mix(in srgb, var(--crm-danger) 40%, var(--crm-border));
  background: color-mix(in srgb, var(--crm-danger) 9%, var(--crm-surface));
}

/* Pipeline como strip dividido (una superficie, no 4 cards) */
.crm-dash2-pipe {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  margin-bottom: 1rem;
  overflow: hidden;
}
.crm-dash2-pipe__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 768px) {
  .crm-dash2-pipe__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.crm-dash2-pipe__seg {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
  min-height: 44px;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  text-decoration: none;
  color: var(--crm-text);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
a.crm-dash2-pipe__seg:hover {
  background: var(--crm-hover);
  color: var(--crm-text);
}
.crm-dash2-pipe__seg:nth-child(2n) {
  border-left: 1px solid var(--crm-border-light);
}
.crm-dash2-pipe__seg:nth-child(n+3) {
  border-top: 1px solid var(--crm-border-light);
}
@media (min-width: 768px) {
  .crm-dash2-pipe__seg:nth-child(n+3) {
    border-top: 0;
  }
  .crm-dash2-pipe__seg + .crm-dash2-pipe__seg {
    border-left: 1px solid var(--crm-border-light);
  }
}
.crm-dash2-pipe__label {
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--crm-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-dash2-pipe__value {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-dash2-pipe__value--text {
  font-size: 0.92rem;
  font-weight: 600;
}
.crm-dash2-pipe__seg--risk .crm-dash2-pipe__value {
  color: var(--crm-danger);
}
.crm-dash2-pipe__seg--bottleneck .crm-dash2-pipe__value {
  color: var(--crm-bottleneck);
}
.crm-dash2-pipe__bar {
  height: 3px;
  background: var(--crm-surface-alt);
  border-top: 1px solid var(--crm-border-light);
}
.crm-dash2-pipe__bar > span {
  display: block;
  height: 100%;
  background: var(--crm-accent);
}
.crm-dash2-pipe__bar--risk > span {
  background: var(--crm-bottleneck);
}

/* Cabecera de panel unificada (sustituye quote-show-panel__head aquí) */
.crm-dash2-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--crm-border-light);
  background: var(--crm-surface);
}
.crm-dash2-panel__titles {
  min-width: 0;
}
.crm-dash2-panel__titles h2 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--crm-text);
  margin: 0;
}
.crm-dash2-panel__title--risk {
  color: var(--crm-danger);
}
.crm-dash2-panel__titles p {
  font-size: 0.72rem;
  color: var(--crm-text-muted);
  margin: 0.1rem 0 0;
}
.crm-dash2-panel__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Notas: fila completa tappable estilo app */
.crm-dash2-note {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.15rem 0;
  text-decoration: none;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.crm-dash2-note:hover {
  color: inherit;
}
.crm-dash2-note__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-top: 0.3rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.crm-dash2-note__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.crm-dash2-note__title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-dash2-note__preview {
  font-size: 0.76rem;
  color: var(--crm-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-dash2-note__time {
  font-size: 0.72rem;
  color: var(--crm-text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Entregas vencidas: fila completa tappable (móvil y desktop) */
.crm-dash2-delivery {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  text-decoration: none;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.crm-dash2-delivery:hover {
  background: var(--crm-hover);
  color: inherit;
}
.crm-dash2-delivery:active {
  background: color-mix(in srgb, var(--crm-accent-light) 55%, var(--crm-hover));
}
.crm-dash2-delivery__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.crm-dash2-delivery__title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-dash2-delivery__meta {
  font-size: 0.74rem;
  color: var(--crm-text-muted);
}
.crm-dash2-delivery__amount {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.crm-dash2-delivery__chev {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--crm-text-muted);
}

/* Enlace de título en la tabla desktop de entregas (data grid sobrio) */
.crm-dash2-tlink {
  color: inherit;
  text-decoration: none;
}
.crm-dash2-tlink:hover {
  color: var(--crm-accent);
  text-decoration: underline;
}

/* Focos visibles */
.crm-dash2-hero:focus-visible,
.crm-dash2-kpi:focus-visible,
a.crm-dash2-pipe__seg:focus-visible,
.crm-dash2-note:focus-visible,
.crm-dash2-delivery:focus-visible,
.crm-dash2-tlink:focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .crm-dash2-pipe__bar > span {
    transition: none;
  }
}

.crm-customer-row,
.crm-app-row {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--crm-border-light);
  background: var(--crm-surface);
}

.crm-customer-row:last-child,
.crm-app-row:last-child {
  border-bottom: 0;
}

.crm-customer-row__main,
.crm-app-row__main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  min-height: 4.25rem;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.15s ease;
}

.crm-customer-row__main:hover,
.crm-customer-row__main:focus-visible,
.crm-app-row__main:hover,
.crm-app-row__main:focus-visible {
  background: var(--crm-hover);
  color: inherit;
}

.crm-customer-row__main:active,
.crm-app-row__main:active {
  background: color-mix(in srgb, var(--crm-accent-light) 55%, var(--crm-hover));
}

.crm-customer-row__avatar,
.crm-app-row__avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.crm-customer-row__body,
.crm-app-row__body {
  flex: 1;
  min-width: 0;
}

.crm-customer-row__top,
.crm-app-row__top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.crm-customer-row__name,
.crm-app-row__name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-customer-row__badge,
.crm-app-row__badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  line-height: 1.1;
}

.crm-customer-row__legal,
.crm-app-row__legal {
  margin-top: 0.1rem;
  font-size: 0.78rem;
  color: var(--crm-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-customer-row__meta,
.crm-app-row__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--crm-text-muted);
  line-height: 1.25;
}

.crm-customer-row__code,
.crm-app-row__code {
  font-weight: 600;
  color: var(--crm-text-secondary);
}

.crm-customer-row__rfc,
.crm-app-row__mono {
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
  letter-spacing: 0.01em;
}

.crm-customer-row__sep,
.crm-app-row__sep {
  opacity: 0.55;
}

.crm-customer-row__chevron,
.crm-app-row__chevron {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--crm-text-muted);
  opacity: 0.7;
}

.crm-customer-row__actions,
.crm-app-row__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  padding: 0 0.9rem 0.75rem;
}
.crm-app-row__actions--3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.crm-customer-row__action,
.crm-app-row__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface-alt);
  color: var(--crm-text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.crm-customer-row__action:hover,
.crm-customer-row__action:focus-visible,
.crm-app-row__action:hover,
.crm-app-row__action:focus-visible {
  color: var(--crm-text);
  background: var(--crm-hover);
  border-color: var(--crm-border);
}

.crm-customer-row__action--edit:hover,
.crm-customer-row__action--edit:focus-visible,
.crm-app-row__action--edit:hover,
.crm-app-row__action--edit:focus-visible {
  color: var(--crm-accent);
  background: var(--crm-accent-light);
  border-color: transparent;
}

.crm-customer-row__action--delete:hover,
.crm-customer-row__action--delete:focus-visible,
.crm-app-row__action--delete:hover,
.crm-app-row__action--delete:focus-visible {
  color: var(--crm-danger);
  background: color-mix(in srgb, var(--crm-danger) 10%, transparent);
  border-color: transparent;
}

/* Products index — fila compacta móvil: contenido + acciones icon-only en una sola fila */
.crm-app-row--compact {
  flex-direction: row;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.4rem 0.4rem 0.75rem;
}
.crm-app-row--compact .crm-app-row__main {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0;
}
.crm-app-row--compact .crm-app-row__avatar {
  width: 2rem;
  height: 2rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.crm-app-row--compact .crm-app-row__top {
  flex-wrap: nowrap;
}
.crm-app-row--compact .crm-app-row__meta {
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.crm-app-row--compact .crm-app-row__actions--inline {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0;
  flex-shrink: 0;
}
.crm-app-row--compact .crm-app-row__action {
  width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--crm-text-muted);
  font-size: 0.9rem;
}
.crm-app-row--compact .crm-app-row__action:active {
  background: var(--crm-hover);
  color: var(--crm-text);
}
.crm-app-row--compact .crm-app-row__action--edit:active {
  color: var(--crm-accent);
  background: var(--crm-accent-light);
}
.crm-app-row--compact .crm-app-row__action--delete:active {
  color: var(--crm-danger);
  background: color-mix(in srgb, var(--crm-danger) 10%, transparent);
}

/* Desktop software data grid refinements */
.crm-customers-table-wrap {
  max-height: calc(100vh - 16rem);
  overflow: auto;
}

.crm-customers-table .crm-customers-table__name {
  display: inline-block;
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1.2;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 22ch;
  vertical-align: bottom;
}

.crm-customers-table .crm-customers-table__legal {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--crm-text-secondary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 28ch;
  vertical-align: bottom;
}

.crm-customers-table .crm-customers-table__code {
  font-weight: 600;
  font-size: 0.8rem;
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
  white-space: nowrap;
}

.crm-customers-table .crm-customers-table__rfc {
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
  font-size: 0.78rem;
  color: var(--crm-text-secondary);
  white-space: nowrap;
}

.crm-customers-table .crm-customers-table__badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  line-height: 1.1;
}

.crm-customers-table .crm-customers-table__address {
  display: inline-block;
  max-width: 28ch;
  font-size: 0.78rem;
  color: var(--crm-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.crm-customers-table .crm-customers-table__address--empty {
  font-style: italic;
  color: var(--crm-text-muted);
}

@media (min-width: 768px) {
  .crm-customers-index {
    gap: 1rem;
    padding-bottom: 0;
  }

  .crm-customers-filters {
    padding: 1rem 1.15rem;
    border-radius: var(--crm-radius-sm);
  }

  .crm-customers-filters .crm-filter-bar {
    grid-template-columns: 2fr 1fr 1fr auto;
    align-items: end;
  }

  .crm-customers-filters .crm-filter-bar__actions {
    display: flex;
  }

  .crm-customers-filters .crm-filter-bar__actions .btn {
    flex: 0 0 auto;
    min-height: 2.5rem;
  }

  .crm-customers-filters .form-control,
  .crm-customers-filters .form-select {
    min-height: 2.5rem;
    font-size: 0.875rem;
  }

  .crm-customers-filters .crm-filter-bar__search-icon {
    top: auto;
    bottom: 0.8rem;
    transform: none;
  }

  .crm-customers-panel {
    border-radius: var(--crm-radius-xs);
    box-shadow: var(--crm-shadow);
  }

  .crm-customers-panel__footer {
    padding: 0.65rem 1rem;
  }

  .crm-customers-table tbody td {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }
}

@media (min-width: 992px) {
  .crm-customers-filters .crm-filter-bar {
    grid-template-columns: 2.5fr 1fr 1.1fr auto;
  }

  .crm-customers-table .crm-customers-table__name {
    max-width: 32ch;
  }

  .crm-customers-table .crm-customers-table__legal {
    max-width: 40ch;
  }

  .crm-customers-table .crm-customers-table__address {
    max-width: 40ch;
  }
}

@media (max-width: 767.98px) {
  .crm-customers-index .crm-page-header {
    margin-bottom: 0;
    gap: 0.5rem;
  }

  .crm-customers-index .crm-page-header__title {
    font-size: 1.35rem;
  }

  .crm-customers-filters {
    border-radius: var(--crm-radius-xs);
    padding: 0.65rem;
  }

  .crm-customers-filters .crm-filter-bar {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .crm-customers-panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    margin-left: -1rem;
    margin-right: -1rem;
  }
}

/* ═══════════════════════════════════════════
   Warehouses index — mobile app list + desktop software grid
   ═══════════════════════════════════════════ */

.crm-warehouses-index {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

.crm-warehouses-filters {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  padding: 0.75rem;
}

.crm-warehouses-filters__form {
  margin: 0;
}

.crm-warehouses-filters__label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
  margin-bottom: 0.35rem;
}

.crm-warehouses-filters .form-control {
  min-height: 2.75rem;
  font-size: 0.9375rem;
}

.crm-warehouses-filters .crm-filter-bar__search {
  display: flex;
  flex-direction: column;
}

.crm-warehouses-filters .crm-filter-bar__search-icon {
  top: auto;
  bottom: 0.9rem;
  transform: none;
}

.crm-warehouses-index .crm-results-count {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
}

.crm-warehouses-panel {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  overflow: hidden;
}

/* Mobile app-style list rows */
.crm-warehouses-list {
  display: flex;
  flex-direction: column;
}

.crm-warehouse-row {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--crm-border-light);
  background: var(--crm-surface);
}

.crm-warehouse-row:last-child {
  border-bottom: 0;
}

.crm-warehouse-row__main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  min-height: 4.25rem;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.15s ease;
}

.crm-warehouse-row__main:hover,
.crm-warehouse-row__main:focus-visible {
  background: var(--crm-hover);
  color: inherit;
}

.crm-warehouse-row__main:active {
  background: color-mix(in srgb, var(--crm-accent-light) 55%, var(--crm-hover));
}

.crm-warehouse-row__avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.crm-warehouse-row__body {
  flex: 1;
  min-width: 0;
}

.crm-warehouse-row__top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.crm-warehouse-row__name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-warehouse-row__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--crm-text-muted);
  line-height: 1.25;
}

.crm-warehouse-row__code {
  font-weight: 600;
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
  color: var(--crm-text-secondary);
}

.crm-warehouse-row__sep {
  opacity: 0.55;
}

.crm-warehouse-row__chevron {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--crm-text-muted);
  opacity: 0.7;
}

.crm-warehouse-row__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  padding: 0 0.9rem 0.75rem;
}

.crm-warehouse-row__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface-alt);
  color: var(--crm-text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.crm-warehouse-row__action:hover,
.crm-warehouse-row__action:focus-visible {
  color: var(--crm-text);
  background: var(--crm-hover);
  border-color: var(--crm-border);
}

.crm-warehouse-row__action--edit:hover,
.crm-warehouse-row__action--edit:focus-visible {
  color: var(--crm-accent);
  background: var(--crm-accent-light);
  border-color: transparent;
}

.crm-warehouse-row__action--delete:hover,
.crm-warehouse-row__action--delete:focus-visible {
  color: var(--crm-danger);
  background: color-mix(in srgb, var(--crm-danger) 10%, transparent);
  border-color: transparent;
}

/* Desktop software data grid refinements */
.crm-warehouses-table-wrap {
  max-height: calc(100vh - 16rem);
  overflow: auto;
}

.crm-warehouses-table .crm-warehouses-table__identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.crm-warehouses-table .crm-warehouses-table__avatar {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.crm-warehouses-table .crm-warehouses-table__names {
  min-width: 0;
}

.crm-warehouses-table .crm-warehouses-table__name {
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1.2;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 28ch;
}

.crm-warehouses-table .crm-warehouses-table__code {
  font-weight: 600;
  font-size: 0.8rem;
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
  white-space: nowrap;
}

.crm-warehouses-table .crm-warehouses-table__manager,
.crm-warehouses-table .crm-warehouses-table__phones {
  font-size: 0.78rem;
  color: var(--crm-text-secondary);
  white-space: nowrap;
}

.crm-warehouses-table .crm-warehouses-table__manager--empty,
.crm-warehouses-table .crm-warehouses-table__phones--empty {
  color: var(--crm-text-muted);
}

.crm-warehouses-table .crm-warehouses-table__address {
  display: inline-block;
  max-width: 28ch;
  font-size: 0.78rem;
  color: var(--crm-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.crm-warehouses-table .crm-warehouses-table__address--empty {
  font-style: italic;
  color: var(--crm-text-muted);
}

@media (min-width: 768px) {
  .crm-warehouses-index {
    gap: 1rem;
    padding-bottom: 0;
  }

  .crm-warehouses-filters {
    padding: 1rem 1.15rem;
    border-radius: var(--crm-radius-sm);
  }

  .crm-warehouses-filters .crm-filter-bar {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .crm-warehouses-filters .crm-filter-bar__actions {
    display: flex;
  }

  .crm-warehouses-filters .crm-filter-bar__actions .btn {
    flex: 0 0 auto;
    min-height: 2.5rem;
  }

  .crm-warehouses-filters .form-control {
    min-height: 2.5rem;
    font-size: 0.875rem;
  }

  .crm-warehouses-filters .crm-filter-bar__search-icon {
    top: auto;
    bottom: 0.8rem;
    transform: none;
  }

  .crm-warehouses-panel {
    border-radius: var(--crm-radius-xs);
    box-shadow: var(--crm-shadow);
  }

  .crm-warehouses-table tbody td {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }
}

@media (min-width: 992px) {
  .crm-warehouses-filters .crm-filter-bar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .crm-warehouses-table .crm-warehouses-table__name {
    max-width: 40ch;
  }

  .crm-warehouses-table .crm-warehouses-table__address {
    max-width: 40ch;
  }
}

@media (max-width: 767.98px) {
  .crm-warehouses-index .crm-page-header {
    margin-bottom: 0;
    gap: 0.5rem;
  }

  .crm-warehouses-index .crm-page-header__title {
    font-size: 1.35rem;
  }

  .crm-warehouses-filters {
    border-radius: var(--crm-radius-xs);
    padding: 0.65rem;
  }

  .crm-warehouses-filters .crm-filter-bar {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .crm-warehouses-panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    margin-left: -1rem;
    margin-right: -1rem;
  }
}

/* ═══════════════════════════════════════════
   Admin users index — mobile app list + desktop software grid
   ═══════════════════════════════════════════ */

.crm-users-index {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

.crm-users-index .crm-results-count {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
}

.crm-users-panel {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  overflow: hidden;
}

/* Mobile app-style list rows */
.crm-users-list {
  display: flex;
  flex-direction: column;
}

.crm-user-row {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--crm-border-light);
  background: var(--crm-surface);
}

.crm-user-row:last-child {
  border-bottom: 0;
}

.crm-user-row__main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  min-height: 4.25rem;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.15s ease;
}

.crm-user-row__main:hover,
.crm-user-row__main:focus-visible {
  background: var(--crm-hover);
  color: inherit;
}

.crm-user-row__main:active {
  background: color-mix(in srgb, var(--crm-accent-light) 55%, var(--crm-hover));
}

.crm-user-row__avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.crm-user-row__body {
  flex: 1;
  min-width: 0;
}

.crm-user-row__top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.crm-user-row__name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-user-row__status {
  margin-top: 0.2rem;
}

.crm-user-row__badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  line-height: 1.1;
}

.crm-user-row__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--crm-text-muted);
  line-height: 1.25;
}

.crm-user-row__email {
  font-weight: 600;
  color: var(--crm-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.crm-user-row__key {
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
}

.crm-user-row__sep {
  opacity: 0.55;
}

.crm-user-row__chevron {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--crm-text-muted);
  opacity: 0.7;
}

.crm-user-row__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  padding: 0 0.9rem 0.75rem;
}

.crm-user-row__actions--single {
  grid-template-columns: 1fr;
}

.crm-user-row__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface-alt);
  color: var(--crm-text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.crm-user-row__action:hover,
.crm-user-row__action:focus-visible {
  color: var(--crm-text);
  background: var(--crm-hover);
  border-color: var(--crm-border);
}

.crm-user-row__action--edit:hover,
.crm-user-row__action--edit:focus-visible {
  color: var(--crm-accent);
  background: var(--crm-accent-light);
  border-color: transparent;
}

.crm-user-row__action--delete:hover,
.crm-user-row__action--delete:focus-visible {
  color: var(--crm-danger);
  background: color-mix(in srgb, var(--crm-danger) 10%, transparent);
  border-color: transparent;
}

/* Desktop software data grid refinements */
.crm-users-table-wrap {
  max-height: calc(100vh - 14rem);
  overflow: auto;
}

.crm-users-table .crm-users-table__identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.crm-users-table .crm-users-table__avatar {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.68rem;
  flex-shrink: 0;
}

.crm-users-table .crm-users-table__names {
  min-width: 0;
}

.crm-users-table .crm-users-table__name {
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1.2;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 24ch;
}

.crm-users-table .crm-users-table__key {
  font-size: 0.72rem;
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
  color: var(--crm-text-muted);
  line-height: 1.2;
  white-space: nowrap;
}

.crm-users-table .crm-users-table__email {
  display: inline-block;
  max-width: 26ch;
  font-size: 0.78rem;
  color: var(--crm-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.crm-users-table .crm-users-table__phone {
  font-size: 0.78rem;
  color: var(--crm-text-secondary);
  white-space: nowrap;
}

.crm-users-table .crm-users-table__phone--empty {
  color: var(--crm-text-muted);
}

.crm-users-table .crm-users-table__badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  line-height: 1.1;
}

.crm-users-table .crm-users-table__last-access {
  font-size: 0.78rem;
  color: var(--crm-text-muted);
  white-space: nowrap;
}

.crm-users-table .crm-users-table__last-access--empty {
  font-style: italic;
}

@media (min-width: 768px) {
  .crm-users-index {
    gap: 1rem;
    padding-bottom: 0;
  }

  .crm-users-panel {
    border-radius: var(--crm-radius-xs);
    box-shadow: var(--crm-shadow);
  }

  .crm-users-table tbody td {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }
}

@media (min-width: 992px) {
  .crm-users-table .crm-users-table__name {
    max-width: 32ch;
  }

  .crm-users-table .crm-users-table__email {
    max-width: 36ch;
  }
}

@media (max-width: 767.98px) {
  .crm-users-index .crm-page-header {
    margin-bottom: 0;
    gap: 0.5rem;
  }

  .crm-users-index .crm-page-header__title {
    font-size: 1.35rem;
  }

  .crm-users-panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    margin-left: -1rem;
    margin-right: -1rem;
  }
}

/* ═══════════════════════════════════════════
   Users form (new / edit) — software sections
   ═══════════════════════════════════════════ */

.crm-users-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 56rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

.crm-users-form__header {
  margin-bottom: 0.25rem;
}

.crm-users-form__identity {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  width: 100%;
}

.crm-users-form__avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  border: 1px solid var(--crm-border);
}

.crm-users-form__identity-text {
  min-width: 0;
  flex: 1;
}

.crm-users-form__identity-text .crm-page-header__subtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-top: 0.2rem;
}

.crm-users-form__email {
  font-size: 0.8125rem;
  color: var(--crm-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.crm-users-form__meta-sep {
  color: var(--crm-text-muted);
}

.crm-users-form__badge {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.45rem;
  border-radius: var(--crm-radius-xs);
}

.crm-users-form__form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.crm-users-form__alert {
  margin: 0;
  border-radius: var(--crm-radius-sm);
  border: 1px solid color-mix(in srgb, var(--crm-danger, #b42318) 35%, var(--crm-border));
}

.crm-form-section {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  overflow: hidden;
  box-shadow: var(--crm-shadow);
}

.crm-form-section__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.7rem 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
  border-bottom: 1px solid var(--crm-border-light);
  background: var(--crm-surface-alt);
}

.crm-form-section__title i {
  color: var(--crm-accent);
  font-size: 0.8rem;
}

.crm-form-section__body {
  padding: 1rem;
}

.crm-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem 1rem;
}

.crm-form-grid--narrow {
  max-width: 28rem;
}

.crm-form-field {
  min-width: 0;
}

.crm-form-field .crm-field-label {
  display: block;
  margin-bottom: 0.35rem;
}

.crm-form-control {
  min-height: 2.5rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface);
  color: var(--crm-text);
  box-shadow: none;
}

.crm-form-control:focus {
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crm-accent) 18%, transparent);
  background: var(--crm-surface);
  color: var(--crm-text);
}

.crm-form-hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--crm-text-muted);
}

.crm-form-permissions {
  display: flex;
  flex-direction: column;
  margin-top: 1rem;
  border: 1px solid var(--crm-border-light);
  border-radius: var(--crm-radius-xs);
  overflow: hidden;
  background: var(--crm-surface-alt);
}

.crm-form-permission {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid var(--crm-border-light);
}

.crm-form-permission:last-child {
  border-bottom: 0;
}

.crm-form-permission__text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}

.crm-form-permission__label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--crm-text);
  line-height: 1.3;
}

.crm-form-permission__hint {
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--crm-text-muted);
}

.crm-form-permission__switch {
  flex-shrink: 0;
  padding-top: 0.1rem;
}

.crm-form-permission__switch .form-check-input {
  width: 2.5rem;
  height: 1.35rem;
  margin: 0;
  cursor: pointer;
}

.crm-customer-credit .form-check-input:checked,
.crm-quote-credit .form-check-input:checked {
  background-color: var(--crm-accent);
  border-color: var(--crm-accent);
}

.crm-customer-credit .form-check-input:focus,
.crm-quote-credit .form-check-input:focus {
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--crm-accent) 25%, transparent);
}

.crm-users-form__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 0 0;
  margin-top: 0.15rem;
  border-top: 1px solid var(--crm-border-light);
  position: sticky;
  bottom: 0;
  background: color-mix(in srgb, var(--crm-bg) 92%, transparent);
  backdrop-filter: blur(6px);
  z-index: 2;
  padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
}

.crm-users-form__footer .btn {
  min-height: 2.5rem;
  min-width: 7.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--crm-radius-xs);
}

@media (min-width: 768px) {
  .crm-users-form {
    gap: 1rem;
  }

  .crm-users-form__avatar {
    width: 3rem;
    height: 3rem;
    font-size: 0.95rem;
  }

  .crm-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crm-form-section__body {
    padding: 1.1rem 1.15rem;
  }

  .crm-users-form__footer {
    padding-top: 1rem;
  }
}

@media (max-width: 767.98px) {
  .crm-users-form .crm-page-header__title {
    font-size: 1.25rem;
  }

  .crm-users-form__footer .btn {
    flex: 1 1 auto;
  }

  .crm-form-permission {
    align-items: center;
  }
}

/* ═══════════════════════════════════════════
   Tax schemas index — mobile app list + desktop software grid
   ═══════════════════════════════════════════ */

.crm-tax-schemas-index {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

.crm-tax-schemas-index .crm-results-count {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
}

.crm-tax-schemas-panel {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  overflow: hidden;
}

.crm-tax-schemas-list {
  display: flex;
  flex-direction: column;
}

.crm-tax-schema-row {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--crm-border-light);
  background: var(--crm-surface);
}

.crm-tax-schema-row:last-child {
  border-bottom: 0;
}

.crm-tax-schema-row__main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  min-height: 4.25rem;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.15s ease;
}

.crm-tax-schema-row__main:hover,
.crm-tax-schema-row__main:focus-visible {
  background: var(--crm-hover);
  color: inherit;
}

.crm-tax-schema-row__main:active {
  background: color-mix(in srgb, var(--crm-accent-light) 55%, var(--crm-hover));
}

.crm-tax-schema-row__avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.crm-tax-schema-row__body {
  flex: 1;
  min-width: 0;
}

.crm-tax-schema-row__top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.crm-tax-schema-row__name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-tax-schema-row__badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  line-height: 1.1;
}

.crm-tax-schema-row__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--crm-text-muted);
  line-height: 1.25;
}

.crm-tax-schema-row__rate {
  font-weight: 600;
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
  color: var(--crm-text-secondary);
}

.crm-tax-schema-row__code {
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
}

.crm-tax-schema-row__default {
  color: #c9a227;
  font-weight: 600;
}

.crm-tax-schema-row__sep {
  opacity: 0.55;
}

.crm-tax-schema-row__chevron {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--crm-text-muted);
  opacity: 0.7;
}

.crm-tax-schema-row__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  padding: 0 0.9rem 0.75rem;
}

.crm-tax-schema-row__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface-alt);
  color: var(--crm-text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.crm-tax-schema-row__action:hover,
.crm-tax-schema-row__action:focus-visible {
  color: var(--crm-text);
  background: var(--crm-hover);
  border-color: var(--crm-border);
}

.crm-tax-schema-row__action--edit:hover,
.crm-tax-schema-row__action--edit:focus-visible {
  color: var(--crm-accent);
  background: var(--crm-accent-light);
  border-color: transparent;
}

.crm-tax-schema-row__action--delete:hover,
.crm-tax-schema-row__action--delete:focus-visible {
  color: var(--crm-danger);
  background: color-mix(in srgb, var(--crm-danger) 10%, transparent);
  border-color: transparent;
}

.crm-tax-schemas-table-wrap {
  max-height: calc(100vh - 14rem);
  overflow: auto;
}

.crm-tax-schemas-table .crm-tax-schemas-table__identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.crm-tax-schemas-table .crm-tax-schemas-table__avatar {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.crm-tax-schemas-table .crm-tax-schemas-table__names {
  min-width: 0;
}

.crm-tax-schemas-table .crm-tax-schemas-table__name {
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1.2;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 22ch;
}

.crm-tax-schemas-table .crm-tax-schemas-table__label {
  font-size: 0.72rem;
  color: var(--crm-text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 28ch;
}

.crm-tax-schemas-table .crm-tax-schemas-table__code {
  font-weight: 600;
  font-size: 0.8rem;
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
  white-space: nowrap;
}

.crm-tax-schemas-table .crm-tax-schemas-table__badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  line-height: 1.1;
}

.crm-tax-schemas-table .crm-tax-schemas-table__rate {
  font-weight: 600;
  font-size: 0.8rem;
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
  white-space: nowrap;
}

.crm-tax-schemas-table .crm-tax-schemas-table__star {
  color: #c9a227;
  font-size: 0.85rem;
}

.crm-tax-schemas-table .crm-tax-schemas-table__empty {
  color: var(--crm-text-muted);
}

@media (min-width: 768px) {
  .crm-tax-schemas-index {
    gap: 1rem;
    padding-bottom: 0;
  }

  .crm-tax-schemas-panel {
    border-radius: var(--crm-radius-xs);
    box-shadow: var(--crm-shadow);
  }

  .crm-tax-schemas-table tbody td {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }
}

@media (min-width: 992px) {
  .crm-tax-schemas-table .crm-tax-schemas-table__name {
    max-width: 32ch;
  }

  .crm-tax-schemas-table .crm-tax-schemas-table__label {
    max-width: 40ch;
  }
}

@media (max-width: 767.98px) {
  .crm-tax-schemas-index .crm-page-header {
    margin-bottom: 0;
    gap: 0.5rem;
  }

  .crm-tax-schemas-index .crm-page-header__title {
    font-size: 1.35rem;
  }

  .crm-tax-schemas-panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    margin-left: -1rem;
    margin-right: -1rem;
  }
}

/* ═══════════════════════════════════════════
   Turbo Native / Hotwire Native
   Unificado con el menú web móvil; safe-areas
   ═══════════════════════════════════════════ */

body[data-turbo-native] .admin-topbar {
  display: none !important;
}

/* Turbo Native ≥ 992px (tablet landscape): no hay topbar de escritorio, así
   que se conserva la barra móvil web en todos los anchos. Sin esto, ambas
   barras quedan ocultas (móvil por `d-lg-none`, escritorio por la regla de
   arriba) pero el wrapper conserva su padding-top → banda vacía superior y
   pérdida de hamburguesa, tema, notificaciones y perfil. */
@media (min-width: 992px) {
  body[data-turbo-native] .admin-mobile-nav {
    display: flex !important;
    /* El riel fijo de escritorio (z 1050) tapa la barra (z 1040): alinearla
       con .admin-main a la derecha del riel, expandido o contraído. */
    left: var(--crm-sidebar-width);
  }
  body[data-turbo-native].sidebar-collapsed .admin-mobile-nav {
    left: var(--crm-sidebar-collapsed);
  }
  /* El riel tampoco tiene padding superior en desktop: evitar que arranque
     bajo los iconos de estado. En web desktop env() vale 0 (sin cambio). */
  body[data-turbo-native] .admin-sidebar {
    padding-top: env(safe-area-inset-top, 0px);
  }
}

body[data-turbo-native] .admin-wrapper {
  padding-top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px));
  min-height: 100dvh;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

body[data-turbo-native] .admin-main {
  min-height: 100dvh;
  width: 100%;
}

body[data-turbo-native] .admin-content {
  padding-top: 0.75rem;
  padding-bottom: max(1.25rem, calc(0.75rem + env(safe-area-inset-bottom, 0px)));
}

body[data-turbo-native] .crm-fab {
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  right: calc(1rem + env(safe-area-inset-right, 0px));
}

/* Spacer final del formulario de cotización en Turbo Native: sin menú inferior no requiere offset */
.crm-quote-form-bottom-spacer {
  display: none;
}
body[data-turbo-native] .crm-quote-form-bottom-spacer {
  display: none;
}

/* En Turbo Native las barras fijas / shells de detalle respetan safe-area sin solape inferior */
body[data-turbo-native] .crm-show-actions-sticky,
body[data-turbo-native] .delivery-route-dock {
  bottom: 0;
  padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
  z-index: 1035;
}

body[data-turbo-native] .delivery-route-dock-spacer {
  height: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

/* El detalle de ventas/servicios */
body[data-turbo-native] .sc-detail-view {
  bottom: 0;
}

/* Visible solo en Turbo Native */
.turbo-native-only {
  display: none !important;
}
body[data-turbo-native] .turbo-native-only {
  display: block !important;
}
body[data-turbo-native] .turbo-native-only.d-flex,
body[data-turbo-native] .turbo-native-only.d-inline-flex {
  display: flex !important;
}

/* Oculto en Turbo Native (mismo HTML cacheable) */
body[data-turbo-native] .turbo-native-hidden {
  display: none !important;
}

/* Sin Turbo Native: ocultar .turbo-native-only ya cubierto arriba */

/* Barra inferior native descontinuada (unificado con el menú móvil web) */
.native-nav {
  display: none !important;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1045;
  align-items: stretch;
  justify-content: space-around;
  gap: 0.15rem;
  min-height: 3.5rem;
  padding: 0.2rem 0.35rem calc(0.25rem + env(safe-area-inset-bottom, 0px));
  background: var(--crm-surface);
  border-top: 1px solid var(--crm-border);
}

.native-nav__item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 44px;
  padding: 0.3rem 0.15rem;
  color: var(--crm-text-secondary);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.native-nav__item i {
  font-size: 1.05rem;
  line-height: 1;
}

.native-nav__item.is-active {
  color: var(--crm-accent);
}

.native-nav__item:hover,
.native-nav__item:focus-visible {
  color: var(--crm-accent);
  text-decoration: none;
}

/* Pantalla Más */
.native-menu__account {
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.native-menu__account-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.native-menu__icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-surface);
  color: var(--crm-text-secondary);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.native-menu__icon-btn:hover,
.native-menu__icon-btn:focus-visible {
  color: var(--crm-accent);
  background: var(--crm-hover);
}

.native-menu__row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0.5rem 0.15rem;
  color: var(--crm-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.native-menu__row i {
  width: 1.15rem;
  color: var(--crm-text-secondary);
  text-align: center;
}

.native-menu__row--danger {
  color: var(--crm-danger);
}

.native-menu__row--danger i {
  color: var(--crm-danger);
}

.native-menu__row:hover,
.native-menu__row:focus-visible {
  color: var(--crm-accent);
  text-decoration: none;
}

.native-menu__modules {
  padding: 0.5rem 0.75rem 1rem;
}

.native-menu__modules .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0.5rem 0.65rem;
  color: var(--crm-text);
  font-size: 0.9rem;
  font-weight: 500;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.native-menu__modules .nav-link i {
  width: 1.15rem;
  color: var(--crm-text-secondary);
  text-align: center;
}

.native-menu__modules .nav-link.active,
.native-menu__modules .nav-link:hover,
.native-menu__modules .nav-link:focus-visible {
  color: var(--crm-accent);
  background: color-mix(in srgb, var(--crm-accent) 8%, transparent);
}

.native-menu__modules .nav-link.active i,
.native-menu__modules .nav-link:hover i {
  color: var(--crm-accent);
}

.native-menu__modules .submenu {
  max-height: none;
  opacity: 1;
  overflow: visible;
  margin: 0 0 0.35rem 0.5rem;
  padding: 0.15rem 0 0.15rem 0.4rem;
  border-left: 2px solid var(--crm-border);
  background: transparent;
}

.native-menu__modules .submenu-section {
  color: var(--crm-text-muted);
}

.native-menu__modules hr {
  border-color: var(--crm-border);
  opacity: 1;
}

/* ═══════════════════════════════════════════
   Analytics — filtros de periodicidad
   ═══════════════════════════════════════════ */

.crm-analytics-filters {
  padding: 0.85rem 1rem;
}

.crm-analytics-filters__bar {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
  align-items: end;
}

.crm-analytics-filters__dates {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr 1fr;
}

.crm-analytics-filters__actions .btn {
  min-height: 2.5rem;
  width: 100%;
}

@media (min-width: 768px) {
  .crm-analytics-filters__bar {
    grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr) auto;
  }

  .crm-analytics-filters__actions .btn {
    width: auto;
    min-width: 6.5rem;
  }
}

/* ── Analytics — grid KPIs y cabeceras de panel ──── */

.crm-analytics-metrics.crm-soft-metrics {
  margin-bottom: 0.85rem;
}

@media (min-width: 768px) {
  .crm-analytics-metrics.crm-soft-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .crm-analytics-metrics.crm-soft-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Cabecera de panel con icono lead */
.crm-analytics-panel__head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--crm-border);
  background: var(--crm-surface-alt, var(--crm-hover));
}

.crm-analytics-panel__head .crm-analytics-panel__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  flex-shrink: 0;
  border-radius: var(--crm-radius-sm);
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  font-size: 0.8rem;
}
.crm-analytics-panel__head .crm-analytics-panel__icon--alert {
  background: color-mix(in srgb, var(--crm-danger) 14%, transparent);
  color: var(--crm-danger);
}

.crm-analytics-panel__head .crm-analytics-panel__titles {
  flex: 1 1 auto;
  min-width: 0;
}

.crm-analytics-panel__head h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  color: var(--crm-text);
  line-height: 1.3;
}

.crm-analytics-panel__head .crm-analytics-panel__sub {
  font-size: 0.75rem;
  color: var(--crm-text-muted);
  margin: 0;
  line-height: 1.3;
}

.crm-analytics-panel__head .crm-analytics-panel__aside {
  font-size: 0.75rem;
  color: var(--crm-text-muted);
  flex-shrink: 0;
}

/* App-row compacta para tablas analytics en móvil */
.crm-analytics-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--crm-border-light);
  background: var(--crm-surface);
}

.crm-analytics-row:last-child {
  border-bottom: 0;
}

.crm-analytics-row__main {
  min-width: 0;
  flex: 1 1 auto;
}

.crm-analytics-row__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--crm-text);
  line-height: 1.3;
}

.crm-analytics-row__meta {
  font-size: 0.72rem;
  color: var(--crm-text-muted);
  margin-top: 0.1rem;
}

.crm-analytics-row__figures {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  flex-shrink: 0;
}

.crm-analytics-row__value {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--crm-text);
}

.crm-analytics-row__hint {
  font-size: 0.7rem;
  color: var(--crm-text-muted);
}


/* ── Toasts flotantes de notificaciones ── */
.crm-toasts {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
  right: calc(env(safe-area-inset-right, 0px) + 0.75rem);
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(360px, calc(100vw - 1.5rem));
  max-width: 360px;
  pointer-events: none;
}
.crm-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border-light);
  border-left: 4px solid var(--crm-accent, #1e3a5f);
  border-radius: var(--crm-radius, 8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  color: var(--crm-text);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
  font-size: 0.85rem;
}
.crm-toast--visible {
  transform: translateX(0);
  opacity: 1;
}
.crm-toast--leaving {
  transform: translateX(120%);
  opacity: 0;
}
.crm-toast--clickable {
  cursor: pointer;
}
.crm-toast--clickable:hover {
  background: color-mix(in srgb, var(--crm-bg) 12%, var(--crm-surface));
}
.crm-toast__icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--crm-accent, #1e3a5f) 14%, transparent);
  color: var(--crm-accent, #1e3a5f);
  font-size: 0.95rem;
}
.crm-toast__body {
  flex: 1 1 auto;
  min-width: 0;
}
.crm-toast__title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--crm-text);
}
.crm-toast__text {
  margin-top: 0.15rem;
  font-size: 0.8rem;
  color: var(--crm-text-secondary);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.crm-toast__close {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--crm-text-muted);
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.crm-toast__close:hover {
  background: color-mix(in srgb, var(--crm-text) 8%, transparent);
  color: var(--crm-text);
}

/* Móvil: full-width respetando safe areas */
@media (max-width: 575.98px) {
  .crm-toasts {
    left: calc(env(safe-area-inset-left, 0px) + 0.75rem);
    right: calc(env(safe-area-inset-right, 0px) + 0.75rem);
    width: auto;
    max-width: none;
  }
}

/* Respetar preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  .crm-toast,
  .crm-toast--visible,
  .crm-toast--leaving {
    transition: none;
    transform: none;
  }
}

/* ── Services views — seguimiento & refacciones ───────────────────── */
/* Presentación provisional de tarjetas (pendiente de definición de diseño).
   Usa variables --crm-* para compatibilidad light/dark. */
.svc-page {
  min-height: 100%;
}

.svc-provisional-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.78rem;
  color: var(--crm-text-muted);
  background: var(--crm-accent-light);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
}
.svc-provisional-note i { color: var(--crm-accent); }

/* Kanban de sub etapas (services/customer_follow_up). Reutiliza las clases
   .kanban-board / .kanban-column / .kanban-stage-header del pipeline. El
   card es clickeable y abre el mismo modal de detalle. Variables --crm-* (light/dark). */
.svc-followup-kanban-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.svc-followup-kanban-card .kanban-card {
  cursor: pointer;
}
.svc-followup-kanban-card .kanban-card:active {
  cursor: pointer;
}

.svc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
}
@media (max-width: 575.98px) {
  .svc-cards {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

.svc-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem 0.9rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-left: 3px solid var(--sc-priority-color, var(--crm-border));
  border-radius: var(--crm-radius-sm);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.svc-card:hover,
.svc-card:focus-visible {
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 1px var(--crm-accent-light);
  outline: none;
}
.svc-card--overdue { border-left-color: var(--crm-danger); }
.svc-card--stale { border-left-color: var(--crm-warning); }

.svc-card__header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.svc-card__stage {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--crm-stage-color, var(--crm-text-muted));
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  background: var(--crm-surface-alt, transparent);
}

.svc-card__case {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--crm-text-muted);
}

.svc-card__meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.svc-card__tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--crm-text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.svc-card__tag i {
  color: var(--crm-text-muted);
  flex-shrink: 0;
}

.svc-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.15rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--crm-border);
}
.svc-card__assignee {
  font-size: 0.75rem;
  color: var(--crm-text-muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.svc-card__date {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
  white-space: nowrap;
}
.svc-card__date--overdue { color: var(--crm-danger); font-weight: 600; }

/* Parts warehouse card */
.svc-parts-card__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
  padding: 0.4rem 0.5rem;
  background: var(--crm-surface-alt, transparent);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
}
.svc-parts-card__summary .font-monospace { color: var(--crm-text); font-weight: 600; }

.svc-parts-card__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-height: 11rem;
  overflow-y: auto;
}
.svc-parts-card__list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.78rem;
  padding: 0.15rem 0;
  border-bottom: 1px dashed var(--crm-border);
}
.svc-parts-card__list li:last-child { border-bottom: 0; }
.svc-parts-card__part-key {
  font-size: 0.72rem;
  color: var(--crm-accent);
  font-weight: 600;
}
.svc-parts-card__part-desc {
  color: var(--crm-text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.svc-parts-card__part-qty {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--crm-text-muted);
  white-space: nowrap;
}
.svc-parts-card__empty {
  margin: 0;
  font-size: 0.78rem;
  color: var(--crm-text-muted);
  font-style: italic;
}

/* ---- Info bar reutilizable (banner de ayuda / flujo) ---- */
.crm-info-bar {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  background-color: color-mix(in srgb, var(--crm-info) 8%, var(--crm-surface-alt));
  border: 1px solid color-mix(in srgb, var(--crm-info) 30%, var(--crm-border));
  border-radius: var(--crm-radius-sm);
  color: var(--crm-text);
  font-size: 0.85rem;
  line-height: 1.4;
}
.crm-info-bar > .crm-info-bar__icon {
  color: var(--crm-info);
  font-size: 1rem;
  flex: 0 0 auto;
  margin-top: 0.1rem;
}
.crm-info-bar__body { flex: 1 1 auto; }
.crm-info-bar__body p { margin: 0; }
.crm-info-bar__body a {
  color: var(--crm-info);
  font-weight: 600;
  text-decoration: none;
}
.crm-info-bar__body a:hover { text-decoration: underline; }

/* ---- Categorías asociadas a una plantilla (formulario de plantilla) ---- */
.crm-template-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.crm-template-categories__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  background-color: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-xs);
  font-size: 0.8rem;
  color: var(--crm-text);
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.crm-template-categories__chip:hover {
  border-color: color-mix(in srgb, var(--crm-accent) 40%, var(--crm-border));
  background-color: var(--crm-surface-alt);
  text-decoration: none;
}
.crm-template-categories__chip .fa { color: var(--crm-accent); }
.crm-template-categories__empty {
  margin: 0;
  font-size: 0.82rem;
  color: var(--crm-text-muted);
  font-style: italic;
}

/* ---- Enlace "Asignar" en índice de categorías (sin formulario) ---- */
.crm-assign-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--crm-info);
  text-decoration: none;
  white-space: nowrap;
}
.crm-assign-link:hover {
  color: var(--crm-info-hover);
  text-decoration: underline;
}

/* ---- Procesos de receta / orden de maquila ---- */
.crm-recipe-process-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.crm-recipe-process-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  background: var(--crm-surface-alt);
}

.crm-recipe-process-row__index {
  flex: 0 0 2rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  font-size: 0.8rem;
}

.crm-recipe-process-row__fields {
  flex: 1 1 auto;
  display: grid;
  gap: 0.5rem;
}

.crm-recipe-process-row__actions {
  flex: 0 0 auto;
  padding-top: 1.6rem;
}

.crm-process-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.crm-process-timeline__item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.crm-process-timeline__step {
  flex: 0 0 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--crm-surface-alt);
  color: var(--crm-text-secondary);
  border: 1px solid var(--crm-border);
}

.crm-process-timeline__item.is-current .crm-process-timeline__step {
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  border-color: var(--crm-accent);
}

.crm-process-timeline__item.is-done .crm-process-timeline__step {
  background: var(--crm-success-bg);
  color: var(--crm-success);
  border-color: color-mix(in srgb, var(--crm-success) 35%, var(--crm-border));
}

.crm-process-timeline__body {
  min-width: 0;
  padding-top: 0.1rem;
}

.crm-process-timeline__name {
  font-weight: 600;
  color: var(--crm-text);
  font-size: 0.88rem;
}

.crm-process-timeline__meta {
  color: var(--crm-text-muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

@media (max-width: 767.98px) {
  .crm-recipe-process-row {
    flex-wrap: wrap;
  }

  .crm-recipe-process-row__fields {
    flex: 1 1 calc(100% - 3rem);
  }

  .crm-recipe-process-row__actions {
    padding-top: 0;
    margin-left: auto;
  }
}

/* Delivery tracking (office follow-up per driver) */
.delivery-tracking {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.delivery-tracking__header {
  margin-bottom: 0;
}

.delivery-tracking__metrics {
  margin-bottom: 0;
}

.delivery-tracking__refresh-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

.delivery-tracking__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

.delivery-tracking-card {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  padding: 0.9rem 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.delivery-tracking-card--idle {
  opacity: 0.92;
}

.delivery-tracking-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.delivery-tracking-card__identity {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.delivery-tracking-card__avatar {
  flex: 0 0 2.25rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--crm-accent-light);
  color: var(--crm-accent);
}

.delivery-tracking-card__name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--crm-text);
  line-height: 1.25;
}

.delivery-tracking-card__meta {
  margin: 0.15rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

.delivery-tracking-card__phone {
  color: var(--crm-text-secondary);
  text-decoration: none;
}

.delivery-tracking-card__phone:hover,
.delivery-tracking-card__phone:focus-visible {
  color: var(--crm-accent);
}

.delivery-tracking-status {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.45rem;
  border-radius: var(--crm-radius-xs);
  border: 1px solid var(--crm-border);
  color: var(--crm-text-muted);
  background: var(--crm-surface-alt);
}

.delivery-tracking-status--live {
  color: var(--crm-success);
  border-color: color-mix(in srgb, var(--crm-success) 35%, var(--crm-border));
  background: var(--crm-success-bg);
}

.delivery-tracking-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--crm-text-muted);
}

.delivery-tracking-location {
  display: flex;
  align-items: stretch;
  gap: 0.65rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-surface-alt);
}

.delivery-tracking-location__body {
  flex: 1;
  min-width: 0;
}

.delivery-tracking-location__label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--crm-text);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.delivery-tracking-location__when {
  margin: 0.2rem 0 0;
  font-size: 0.72rem;
  color: var(--crm-text-muted);
}

.delivery-tracking-map-btn {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.35rem 0.55rem;
  border-radius: var(--crm-radius-sm);
  border: 1px solid var(--crm-border);
  background: var(--crm-surface);
  color: var(--crm-accent);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  touch-action: manipulation;
}

.delivery-tracking-map-btn:hover,
.delivery-tracking-map-btn:focus-visible {
  background: var(--crm-accent-light);
  color: var(--crm-accent);
}

.delivery-tracking-now,
.delivery-tracking-next,
.delivery-tracking-rest {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.delivery-tracking-next__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.delivery-tracking-eta {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--crm-accent);
  white-space: nowrap;
}

.delivery-tracking-eta--sm {
  font-size: 0.72rem;
}

.delivery-tracking-stops {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.delivery-tracking-stop {
  display: grid;
  grid-template-columns: 1.75rem 1fr auto;
  gap: 0.55rem;
  align-items: start;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-surface);
}

.delivery-tracking-stop--current {
  border-color: color-mix(in srgb, var(--crm-accent) 40%, var(--crm-border));
  background: color-mix(in srgb, var(--crm-accent-light) 55%, var(--crm-surface));
}

.delivery-tracking-stop--next {
  border-color: color-mix(in srgb, var(--crm-accent) 22%, var(--crm-border));
}

.delivery-tracking-stop__rail {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--crm-accent);
  background: var(--crm-accent-light);
}

.delivery-tracking-stop__body {
  min-width: 0;
}

.delivery-tracking-stop__title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.delivery-tracking-stop__title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--crm-text);
  line-height: 1.3;
}

.delivery-tracking-stop__customer,
.delivery-tracking-stop__address,
.delivery-tracking-stop__contact {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--crm-text-secondary);
  line-height: 1.35;
}

.delivery-tracking-stop__address {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--crm-text-muted);
}

.delivery-tracking-stop__map {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--crm-text-secondary);
  text-decoration: none;
  touch-action: manipulation;
}

.delivery-tracking-stop__map:hover,
.delivery-tracking-stop__map:focus-visible {
  color: var(--crm-accent);
}

.delivery-tracking-card__route,
.delivery-tracking-empty-line {
  margin: 0;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

.delivery-tracking-unassigned {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  padding: 0.9rem 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.delivery-tracking-unassigned__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--crm-text);
}

.delivery-tracking-unassigned__hint {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

.delivery-tracking-empty {
  text-align: center;
  padding: 2rem 1rem;
  border: 1px dashed var(--crm-border);
  border-radius: var(--crm-radius);
  background: var(--crm-surface);
}

.delivery-tracking-empty__icon {
  font-size: 1.6rem;
  color: var(--crm-text-muted);
  margin-bottom: 0.5rem;
}

.delivery-tracking-empty__title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--crm-text);
}

.delivery-tracking-empty__text {
  margin: 0;
  font-size: 0.85rem;
  color: var(--crm-text-secondary);
}

@media (min-width: 768px) {
  .delivery-tracking__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .delivery-tracking__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}



/* ───────────────────────────────────────────────────────────────────────
   Service status — vista pública (tracker estilo Domino's)
   Compatible light + dark. Solo variables --crm-* y --step-color.
   ─────────────────────────────────────────────────────────────────────── */

.service-status-shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  color: var(--crm-text);
  min-height: 100dvh;
  box-sizing: border-box;
}

.service-status-shell--result {
  max-width: 720px;
}

.service-status-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.service-status-logo {
  width: 3rem;
  height: 3rem;
  border-radius: var(--crm-radius);
  background: var(--crm-accent-light);
  color: var(--crm-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.service-status-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--crm-text);
}

.service-status-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--crm-text-secondary);
}

.service-status-card {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  padding: 1.5rem;
  box-shadow: var(--crm-shadow-md);
}

.service-status-card--result {
  padding: 1.75rem;
}

.service-status-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--crm-radius-sm);
  background: color-mix(in srgb, var(--crm-danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--crm-danger) 30%, transparent);
  color: var(--crm-danger);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.service-status-alert i { margin-top: 0.15rem; }

.service-status-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.service-status-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.service-status-field label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--crm-text-secondary);
}

.service-status-field input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-surface-alt);
  color: var(--crm-text);
  font-size: 1rem;
  font-family: "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.04em;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.service-status-field input:focus {
  outline: none;
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crm-accent) 18%, transparent);
}

.service-status-field__hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

.service-status-submit {
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--crm-radius-sm);
  background: var(--crm-accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.service-status-submit:hover { background: var(--crm-accent-hover); }
.service-status-submit:active { transform: translateY(1px); }

.service-status-foot {
  text-align: center;
  font-size: 0.78rem;
  color: var(--crm-text-muted);
  margin: 0;
}

/* ── Resultado: cabecera del caso ──────────────────────────────────────── */

.service-status-case {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--crm-border);
}

.service-status-case__folio {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.service-status-case__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--crm-text-muted);
}

.service-status-case__number {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--crm-text);
}

.service-status-case__stage {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: var(--step-color, var(--crm-accent));
  white-space: nowrap;
}

.service-status-case__title {
  margin: 0 0 1.25rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--crm-text-secondary);
}

.service-status-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-start;
}

.service-status-back {
  display: inline-flex;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--crm-accent);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--crm-radius-sm);
  transition: background 0.15s ease;
}

.service-status-back:hover {
  background: var(--crm-accent-light);
  text-decoration: none;
}

/* ── Tracker de etapas ─────────────────────────────────────────────────── */

.status-tracker {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.status-tracker__step {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.75rem;
  padding-bottom: 1rem;
  position: relative;
}

.status-tracker__step:last-child { padding-bottom: 0; }

.status-tracker__node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.status-tracker__icon {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  background: var(--crm-surface-alt);
  border: 2px solid var(--crm-border);
  color: var(--crm-text-muted);
  z-index: 1;
}

.status-tracker__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--crm-text-muted);
  opacity: 0.5;
}

.status-tracker__connector {
  position: absolute;
  top: 2rem;
  bottom: -1rem;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--crm-border);
}

.status-tracker__step:last-child .status-tracker__connector { display: none; }

.status-tracker__body {
  padding-top: 0.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.status-tracker__label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--crm-text);
}

.status-tracker__state {
  margin: 0;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}

/* Estados */
.status-tracker__step.is-completed .status-tracker__icon {
  background: var(--step-color, var(--crm-success));
  border-color: var(--step-color, var(--crm-success));
  color: #fff;
}

.status-tracker__step.is-completed + .status-tracker__step .status-tracker__connector,
.status-tracker__step.is-completed .status-tracker__connector {
  background: var(--step-color, var(--crm-success));
}

.status-tracker__step.is-completed .status-tracker__state--completed {
  color: var(--crm-success);
}

.status-tracker__step.is-current .status-tracker__icon {
  background: var(--step-color, var(--crm-accent));
  border-color: var(--step-color, var(--crm-accent));
  color: #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--step-color, var(--crm-accent)) 22%, transparent);
}

.status-tracker__pulse {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: #fff;
  animation: status-tracker-pulse 1.6s ease-in-out infinite;
}

@keyframes status-tracker-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.6); opacity: 0.6; }
}

.status-tracker__step.is-current .status-tracker__label {
  color: var(--step-color, var(--crm-accent));
}

.status-tracker__step.is-current .status-tracker__state--current {
  color: var(--step-color, var(--crm-accent));
  font-weight: 600;
}

.status-tracker__step.is-final .status-tracker__icon {
  background: var(--step-color, var(--crm-success));
  border-color: var(--step-color, var(--crm-success));
  color: #fff;
}

.status-tracker__step.is-final .status-tracker__label {
  color: var(--step-color, var(--crm-success));
}

.status-tracker__step.is-final .status-tracker__state--final {
  color: var(--step-color, var(--crm-success));
  font-weight: 600;
}

.status-tracker__step.is-pending .status-tracker__label {
  color: var(--crm-text-secondary);
}

/* ── Bloque código de seguridad en card kanban ─────────────────────────── */

.kanban-card-security-code {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.kanban-card-security-code__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-surface-alt);
}

.kanban-card-security-code__label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--crm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.kanban-card-security-code__value {
  flex: 1;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--crm-text);
  letter-spacing: 0.08em;
}

.kanban-card-security-code__actions {
  display: inline-flex;
  gap: 0.25rem;
}

.kanban-card-security-code__btn {
  padding: 0.15rem 0.4rem;
  font-size: 0.7rem;
  line-height: 1;
}

.kanban-card-security-code__generate {
  font-size: 0.75rem;
  font-weight: 600;
}

.kanban-card-security-code__hint {
  font-size: 0.68rem;
  color: var(--crm-success);
  padding: 0 0.25rem;
}

/* ── Responsive: tracker horizontal en desktop ─────────────────────────── */

@media (min-width: 768px) {
  .status-tracker {
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
  }

  .status-tracker__step {
    grid-template-columns: 1fr;
    grid-template-rows: 2rem 1fr;
    flex: 1;
    padding-bottom: 0;
    padding-right: 0.5rem;
    text-align: center;
    align-items: center;
    justify-items: center;
  }

  .status-tracker__node {
    flex-direction: row;
    align-items: center;
    width: 100%;
    justify-content: center;
  }

  .status-tracker__connector {
    top: 50%;
    bottom: auto;
    left: 50%;
    right: auto;
    width: 100%;
    height: 2px;
    transform: translate(50%, -50%);
    z-index: 0;
  }

  .status-tracker__step:last-child .status-tracker__connector { display: none; }

  .status-tracker__body {
    align-items: center;
    text-align: center;
    padding-top: 0.75rem;
  }
}

/* ═══════════════════════════════════════════
   Company setting — show + form
   ═══════════════════════════════════════════ */

.crm-company-setting-page {
  padding-bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  .crm-company-setting-page {
    padding-bottom: 0;
  }

  .crm-company-setting-page .crm-page-header {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }

  .crm-company-setting-page .crm-page-header__actions {
    width: auto;
    flex: 0 0 auto;
  }

  .crm-company-setting-page .crm-page-header__actions .btn {
    flex: 0 0 auto;
    min-width: 7.5rem;
  }
}

.crm-company-setting-address-summary {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--crm-border-light);
}

.crm-company-setting-address-summary p {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--crm-text-secondary);
  line-height: 1.45;
}

.crm-company-setting-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

.crm-company-setting-form__form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.crm-company-setting-form__alert {
  margin: 0;
  border-radius: var(--crm-radius-sm);
  border: 1px solid color-mix(in srgb, var(--crm-danger, #b42318) 35%, var(--crm-border));
}

.crm-company-setting-form__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 0 0;
  margin-top: 0.15rem;
  border-top: 1px solid var(--crm-border-light);
  position: sticky;
  bottom: 0;
  background: color-mix(in srgb, var(--crm-bg) 92%, transparent);
  backdrop-filter: blur(6px);
  z-index: 2;
  padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
}

.crm-company-setting-form__footer .btn {
  min-height: 2.5rem;
  min-width: 7.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--crm-radius-xs);
}

@media (max-width: 767.98px) {
  .crm-company-setting-page .crm-index-panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    margin-left: -1rem;
    margin-right: -1rem;
  }

  .crm-company-setting-form__footer .btn {
    flex: 1 1 auto;
  }
}

/* ═══════════════════════════════════════════
   Refinamiento UI/UX global — desktop + Turbo Native
   (plan: plans/mejora_diseno_desktop_turbo_native_ux.md)
   Solo tokens --crm-*; sin paletas, fuentes ni gradientes nuevos.
   ═══════════════════════════════════════════ */

/* ── Tokens de motion + ritmo ── */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --crm-motion-fast: 120ms;
  --crm-motion-base: 180ms;
  --crm-motion-slow: 280ms;
  --crm-ease-out: cubic-bezier(0.2, 0, 0, 1);
  --crm-ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --crm-focus-ring: 0 0 0 2px var(--crm-surface), 0 0 0 4px var(--crm-accent);
  --crm-tap-min: 44px;
}

/* ── Foco visible coherente (teclado) ── */
.admin-body :focus-visible {
  outline: none;
  box-shadow: var(--crm-focus-ring);
  border-radius: var(--crm-radius-xs);
}
.admin-body .btn:focus-visible,
.admin-body .form-control:focus-visible,
.admin-body .form-select:focus-visible {
  box-shadow: var(--crm-focus-ring);
}

/* ── Sistema de iconos: tamaños + línea base ── */
.crm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 1;
}
.crm-icon--xs { width: 1rem; height: 1rem; font-size: 0.7rem; }
.crm-icon--sm { width: 1.25rem; height: 1.25rem; font-size: 0.8rem; }
.crm-icon--md { width: 1.5rem; height: 1.5rem; font-size: 0.95rem; }
.crm-icon--lg { width: 2rem; height: 2rem; font-size: 1.15rem; }
/* Alineación icono-texto en navegación y acciones */
.admin-sidebar .nav-link > i,
.native-menu__row > i,
.native-menu__modules .nav-link > i,
.btn-action > i,
.crm-app-row__action > i {
  flex: 0 0 auto;
}
.btn .fas, .btn .far, .btn .fa-solid {
  line-height: inherit;
}

/* ── Desktop: data grid Dynamics — fluidez y densidad ── */
@media (min-width: 768px) {
  .crm-data-table tbody tr {
    transition: background-color var(--crm-motion-fast) var(--crm-ease-out);
  }
  .crm-data-table.table-hover tbody tr:hover {
    background-color: color-mix(in srgb, var(--crm-accent) 7%, var(--crm-hover));
  }
  .crm-data-table thead th {
    box-shadow: inset 0 -1px 0 var(--crm-border);
  }
  /* Números tabulares para columnas de importes/cantidades */
  .crm-data-table .text-end,
  .crm-data-table td[data-numeric] {
    font-variant-numeric: tabular-nums;
  }
  /* Fila seleccionada / resaltada */
  .crm-data-table tbody tr.is-selected,
  .crm-data-table tbody tr.table-active {
    background-color: color-mix(in srgb, var(--crm-accent) 10%, transparent);
  }
  /* Contenedor del grid con scroll interno y cabecera fija */
  .crm-grid-scroll {
    max-height: min(70vh, 42rem);
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-sm);
    background: var(--crm-surface);
  }
  .crm-grid-scroll .crm-data-table thead th {
    top: 0;
  }
}

/* ── Cabeceras de página + barras de filtro: ritmo vertical ── */
.crm-page-header {
  row-gap: 0.65rem;
}
.crm-page-header__title {
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.crm-filter-bar .form-control,
.crm-filter-bar .form-select {
  min-height: 2.5rem;
}
.crm-filter-bar .btn {
  min-height: 2.5rem;
}

/* ── Botones flat: transiciones y estados ── */
.admin-body .btn {
  transition: background-color var(--crm-motion-fast) var(--crm-ease-out),
              border-color var(--crm-motion-fast) var(--crm-ease-out),
              color var(--crm-motion-fast) var(--crm-ease-out),
              box-shadow var(--crm-motion-fast) var(--crm-ease-out);
}
.admin-body .btn:active {
  filter: brightness(0.96);
}
[data-bs-theme="dark"] .admin-body .btn:active {
  filter: brightness(1.12);
}
.admin-body .btn:disabled,
.admin-body .btn.disabled {
  opacity: 0.55;
}
.btn-action {
  transition: background-color var(--crm-motion-fast) var(--crm-ease-out),
              color var(--crm-motion-fast) var(--crm-ease-out);
}
.btn-action:active {
  transform: translateY(1px);
}

/* ── Formularios: foco y ritmo ── */
.admin-body .form-control,
.admin-body .form-select {
  border-radius: var(--crm-radius-sm);
  transition: border-color var(--crm-motion-fast) var(--crm-ease-out),
              box-shadow var(--crm-motion-fast) var(--crm-ease-out),
              background-color var(--crm-motion-fast) var(--crm-ease-out);
}
.admin-body .form-control:focus,
.admin-body .form-select:focus {
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crm-accent) 22%, transparent);
}
.admin-body .form-label {
  margin-bottom: 0.3rem;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--crm-text-secondary);
}
.admin-body .form-text {
  margin-top: 0.3rem;
  font-size: 0.75rem;
}
.admin-body .input-group > .form-control:not(:last-child),
.admin-body .input-group > .form-select:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.admin-body .input-group > .btn:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* ── Dropdowns: densidad y ritmo ── */
.admin-body .dropdown-menu {
  border-radius: var(--crm-radius-sm);
  border: 1px solid var(--crm-border);
  box-shadow: var(--crm-shadow-md);
  padding: 0.35rem;
}
.admin-body .dropdown-item {
  border-radius: var(--crm-radius-xs);
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  transition: background-color var(--crm-motion-fast) var(--crm-ease-out),
              color var(--crm-motion-fast) var(--crm-ease-out);
}

/* ── Modales: radios y ritmo ── */
.admin-body .modal-content {
  border-radius: var(--crm-radius);
  border: 1px solid var(--crm-border);
  box-shadow: var(--crm-shadow-lg);
}
.admin-body .modal-header {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--crm-border-light);
}
.admin-body .modal-body {
  padding: 1.1rem;
}
.admin-body .modal-footer {
  padding: 0.8rem 1.1rem;
  border-top: 1px solid var(--crm-border-light);
  gap: 0.5rem;
}
.admin-body .modal-title {
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* ── Badges/chips compactos ── */
.admin-body .badge {
  font-weight: 600;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

/* ── Paginación compacta alineada al grid ── */
.crm-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.6rem 0.1rem 0;
}
.crm-pagination .pagination {
  margin-bottom: 0;
  gap: 0.15rem;
}
.crm-pagination .page-link {
  border-radius: var(--crm-radius-xs);
  min-width: 2rem;
  min-height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--crm-motion-fast) var(--crm-ease-out),
              color var(--crm-motion-fast) var(--crm-ease-out);
}

/* ── Sidebar desktop: ritmo y feedback ── */
@media (min-width: 992px) {
  .admin-sidebar .sidebar-nav {
    padding: 0.5rem 0.35rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--crm-scroll-thumb) transparent;
  }
  .admin-sidebar .nav-link {
    min-height: 2.5rem;
  }
  .admin-sidebar .nav-link:focus-visible {
    box-shadow: inset 0 0 0 2px var(--crm-sidebar-accent);
  }
}

/* ── Topbar desktop: ritmo ── */
.admin-topbar .btn {
  min-height: 2.375rem;
}

/* ── Turbo Native: barra inferior con píldora activa ── */
body[data-turbo-native] .native-nav {
  gap: 0.25rem;
  padding-left: max(0.5rem, env(safe-area-inset-left, 0px));
  padding-right: max(0.5rem, env(safe-area-inset-right, 0px));
}
.native-nav__item {
  position: relative;
  border-radius: var(--crm-radius-sm);
  transition: background-color var(--crm-motion-fast) var(--crm-ease-out),
              color var(--crm-motion-fast) var(--crm-ease-out);
}
.native-nav__item i {
  transition: transform var(--crm-motion-fast) var(--crm-ease-out);
}
.native-nav__item:active i {
  transform: scale(0.9);
}
.native-nav__item.is-active {
  background: var(--crm-accent-light);
}
.native-nav__item.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 1.1rem;
  height: 3px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: var(--crm-accent);
}
.native-nav__item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--crm-accent);
}

/* ── Turbo Native / móvil: filas app con feedback táctil ── */
.crm-app-row,
.native-menu__row,
.native-menu__modules .nav-link {
  transition: background-color var(--crm-motion-fast) var(--crm-ease-out),
              color var(--crm-motion-fast) var(--crm-ease-out);
}
.crm-app-row:active,
.native-menu__row:active {
  background-color: color-mix(in srgb, var(--crm-accent) 8%, var(--crm-hover));
}
.crm-app-row .crm-app-row__chevron,
.crm-app-row .fa-chevron-right {
  transition: transform var(--crm-motion-fast) var(--crm-ease-out);
}
.crm-app-row:active .crm-app-row__chevron,
.crm-app-row:active .fa-chevron-right {
  transform: translateX(2px);
}
/* Respetar safe areas laterales en contenido native */
body[data-turbo-native] .admin-content {
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
}

/* ── FAB: transición y presión ── */
.crm-fab {
  transition: background-color var(--crm-motion-fast) var(--crm-ease-out),
              color var(--crm-motion-fast) var(--crm-ease-out),
              transform var(--crm-motion-fast) var(--crm-ease-out),
              box-shadow var(--crm-motion-base) var(--crm-ease-out);
}
.crm-fab:active {
  transform: scale(0.94);
}
body[data-turbo-native] .crm-fab {
  bottom: calc(var(--crm-native-nav-height) + 1rem + env(safe-area-inset-bottom, 0px));
}

/* ── Skeleton reutilizable para cargas (light + dark) ── */
.crm-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--crm-border-light);
  border-radius: var(--crm-radius-xs);
  min-height: 1em;
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}
.crm-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--crm-text-muted) 18%, transparent);
  transform: translateX(-100%);
  animation: crm-skeleton-sweep 1.4s var(--crm-ease-standard) infinite;
}
@keyframes crm-skeleton-sweep {
  100% { transform: translateX(100%); }
}

/* ── Diferir pintura bajo el pliegue ── */
.crm-defer-paint {
  content-visibility: auto;
  contain-intrinsic-size: auto 24rem;
}

/* ── Scrollbars finas en desktop (sidebar, grids, paneles) ── */
@media (hover: hover) and (pointer: fine) {
  .crm-grid-scroll,
  .crm-data-table-responsive,
  .submenu.open {
    scrollbar-width: thin;
    scrollbar-color: var(--crm-scroll-thumb) var(--crm-scroll-track);
  }
  .crm-grid-scroll::-webkit-scrollbar,
  .crm-data-table-responsive::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  .crm-grid-scroll::-webkit-scrollbar-thumb,
  .crm-data-table-responsive::-webkit-scrollbar-thumb {
    background: var(--crm-scroll-thumb);
    border-radius: 999px;
  }
  .crm-grid-scroll::-webkit-scrollbar-track,
  .crm-data-table-responsive::-webkit-scrollbar-track {
    background: var(--crm-scroll-track);
  }
}

/* ── Profile menu — topbar desktop + barra móvil (mobile-first) ── */
.crm-profile {
  position: relative;
}

/* Trigger: 44px táctil, sin caret de Bootstrap */
.crm-profile__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.3rem;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: var(--crm-radius-sm);
  color: var(--crm-text);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--crm-motion-fast) var(--crm-ease-out),
              border-color var(--crm-motion-fast) var(--crm-ease-out);
}
.crm-profile__trigger:hover {
  background-color: var(--crm-hover);
}
.crm-profile__trigger:focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: 2px;
}
.crm-profile__trigger--pill {
  min-height: 2.375rem;
  padding: 0.3rem 0.7rem 0.3rem 0.35rem;
  background-color: var(--crm-surface);
  border-color: var(--crm-border);
  border-radius: var(--crm-radius);
}
.crm-profile__trigger-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  min-width: 0;
}
.crm-profile__trigger-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--crm-text);
  white-space: nowrap;
}
.crm-profile__trigger-role {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--crm-text-muted);
  white-space: nowrap;
}
.crm-profile__chevron {
  font-size: 0.7rem;
  color: var(--crm-text-muted);
}

/* Avatar de iniciales: solo tokens --crm-* */
.crm-profile__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background-color: color-mix(in srgb, var(--crm-accent) 82%, black);
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 2px solid var(--crm-border);
}
.crm-profile__avatar--xs {
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.65rem;
}
.crm-profile__avatar--sm {
  width: 2rem;
  height: 2rem;
  font-size: 0.72rem;
}
.crm-profile__avatar--lg {
  width: 2.75rem;
  height: 2.75rem;
  font-size: 0.95rem;
}

/* Panel del menú */
.dropdown-menu.crm-profile__menu {
  width: min(20rem, calc(100vw - 1.5rem));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  background-color: var(--crm-surface);
  box-shadow: var(--crm-shadow-lg);
  margin-top: 0.35rem !important;
}

/* Header con identidad */
.crm-profile__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background-color: var(--crm-surface-alt);
  border-bottom: 1px solid var(--crm-border-light);
}
.crm-profile__identity {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  min-width: 0;
  flex: 1 1 auto;
}
.crm-profile__name {
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--crm-text);
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-profile__email {
  font-size: 0.75rem;
  color: var(--crm-text-secondary);
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-profile__role {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.3rem 0.55rem;
  margin-top: 0.2rem;
  border-radius: 999px;
  white-space: nowrap;
  background-color: var(--crm-bg);
  border: 1px solid var(--crm-border-light);
  color: var(--crm-text-secondary);
}

/* Filas de app: icono tile + label + desc + chevron */
.crm-profile__list {
  display: flex;
  flex-direction: column;
  padding: 0.35rem;
}
.crm-profile__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.25rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--crm-radius-sm);
  color: var(--crm-text);
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--crm-motion-fast) var(--crm-ease-out);
}
.crm-profile__item:hover {
  background-color: var(--crm-hover);
  color: var(--crm-text);
}
.crm-profile__item:focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: -2px;
}
.crm-profile__item:active {
  background-color: color-mix(in srgb, var(--crm-accent) 8%, var(--crm-hover));
}
.crm-profile__item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: var(--crm-radius-sm);
  font-size: 0.85rem;
  background-color: var(--crm-accent-light);
  color: var(--crm-accent);
}
.crm-profile__item-icon--danger {
  background-color: color-mix(in srgb, var(--crm-danger) 10%, transparent);
  color: var(--crm-danger);
}
.crm-profile__item-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-width: 0;
  flex: 1 1 auto;
}
.crm-profile__item-label {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.25;
  color: inherit;
}
.crm-profile__item-desc {
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--crm-text-muted);
}
.crm-profile__item--danger .crm-profile__item-label {
  color: var(--crm-danger);
}
.crm-profile__item--danger:hover {
  background-color: color-mix(in srgb, var(--crm-danger) 7%, transparent);
}
.crm-profile__item-chevron {
  font-size: 0.7rem;
  color: var(--crm-text-muted);
  flex: 0 0 auto;
  transition: transform var(--crm-motion-fast) var(--crm-ease-out);
}
.crm-profile__item:active .crm-profile__item-chevron {
  transform: translateX(2px);
}

/* Footer desktop */
.crm-profile__footer {
  padding: 0.5rem 1rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--crm-text-muted);
  border-top: 1px solid var(--crm-border-light);
  text-align: center;
}

/* ── Profile menu: hoja fija en móvil (< 992px) ── */
@media (max-width: 991.98px) {
  .admin-mobile-nav .crm-profile__menu,
  .admin-mobile-nav .crm-profile__menu[data-bs-popper] {
    position: fixed !important;
    top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px) + 0.5rem) !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    width: auto;
    margin-top: 0 !important;
    transform: none !important;
    z-index: 1050;
  }
  .admin-mobile-nav .crm-profile__header {
    padding: 1rem;
  }
  .admin-mobile-nav .crm-profile__item {
    min-height: 3.5rem;
    padding: 0.65rem 0.75rem;
  }
  .admin-mobile-nav .crm-profile__item-label {
    font-size: 0.9rem;
  }
  .admin-mobile-nav .crm-profile__item-desc {
    font-size: 0.76rem;
  }
}

/* ── Accesos directos: dropdown con grid 3×3 (desktop + móvil/Turbo Native) ── */
.crm-shortcuts__menu {
  width: min(400px, calc(100vw - 1.5rem));
  padding: 0;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  background-color: var(--crm-surface);
  overflow: hidden;
  margin-top: 0.35rem !important;
  box-shadow: var(--crm-shadow-lg);
}

.crm-shortcuts__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--crm-border-light);
  background-color: var(--crm-surface-alt, var(--crm-bg));
}

.crm-shortcuts__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--crm-text);
}

.crm-shortcuts__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.375rem 0.5rem;
  border: 0;
  border-radius: var(--crm-radius-sm);
  background: transparent;
  color: var(--crm-text-secondary);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.crm-shortcuts__close:hover {
  background-color: var(--crm-hover, var(--crm-bg));
  color: var(--crm-text);
}

.crm-shortcuts__close:focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: 2px;
}

.crm-shortcuts__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0.875rem 1rem 1rem;
}

.crm-shortcuts__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 88px;
  padding: 0.875rem 0.5rem;
  border: 1px solid var(--crm-border-light);
  border-radius: var(--crm-radius);
  background-color: var(--crm-surface);
  color: var(--crm-text);
  text-decoration: none;
  text-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.crm-shortcuts__cell:hover {
  background-color: var(--crm-hover, var(--crm-bg));
  border-color: var(--crm-border);
  color: var(--crm-text);
  text-decoration: none;
}

.crm-shortcuts__cell:focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: 2px;
}

.crm-shortcuts__cell:active {
  background-color: var(--crm-active, var(--crm-hover, var(--crm-bg)));
}

.crm-shortcuts__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--crm-accent);
}

.crm-shortcuts__label {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--crm-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Accesos directos: panel tipo hoja en móvil (< 992px) ── */
@media (max-width: 991.98px) {
  .admin-mobile-nav .crm-shortcuts__menu,
  .admin-mobile-nav .crm-shortcuts__menu[data-bs-popper] {
    position: fixed !important;
    top: calc(var(--crm-topbar-height, 48px) + env(safe-area-inset-top, 0px) + 0.5rem) !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    width: auto;
    margin-top: 0 !important;
    transform: none !important;
    z-index: 1050;
    display: none;
    flex-direction: column;
    max-height: calc(70dvh + env(safe-area-inset-bottom, 0px));
  }

  .admin-mobile-nav .crm-shortcuts__menu.show {
    display: flex;
  }

  .admin-mobile-nav .crm-shortcuts__header {
    flex: 0 0 auto;
    padding: 0.75rem 0.875rem;
  }

  .admin-mobile-nav .crm-shortcuts__grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    gap: 0.625rem;
    padding: 0.875rem;
  }

  .admin-mobile-nav .crm-shortcuts__cell {
    min-height: 96px;
    padding: 1rem 0.5rem;
  }

  .admin-mobile-nav .crm-shortcuts__icon {
    font-size: 1.625rem;
  }

  .admin-mobile-nav .crm-shortcuts__label {
    font-size: 0.8125rem;
  }
}

/* ── Movimiento reducido: sin animaciones ni transiciones ── */
@media (prefers-reduced-motion: reduce) {
  .admin-body *,
  .admin-body *::before,
  .admin-body *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .crm-skeleton::after {
    animation: none;
  }
}
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *



 */
