/* Factura Legal — application styles.
 * The base is the approved visual spec (mockup-sistema-facturacion-v4.html);
 * the block at the end adds what a live application needs and the static mockup
 * did not: login, flash messages, action menus, empty states and forms. */

:root {
  --red: #e01e25;
  --red-h: #b5161c;
  --green: #1e9e63;
  --bg: #f5f4f2;
  --line: #e4e1dd;
  --line-2: #d6d2cc;
  --t1: #1b1917;
  --t2: #5f5852;
  --t3: #8c847c;
  --side: #1a1817;
  --side-t: #c9c3bc;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 13px;
  color: var(--t1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a {
  color: inherit;
  text-decoration: none;
}
.num {
  font-variant-numeric: tabular-nums;
}
.app {
  display: flex;
  min-height: 100vh;
}
.side {
  width: 236px;
  flex: none;
  background: var(--side);
  color: var(--side-t);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex: none;
}
.brand .w {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 19px;
  color: #fff;
  letter-spacing: -0.02em;
}
.brand .w i {
  font-style: normal;
  color: var(--red);
}
.brand .p {
  font-size: 10.5px;
  color: #8b847d;
  margin-left: auto;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.nav {
  padding: 8px 8px 14px;
  display: grid;
  gap: 1px;
}
.nav .g {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6e6862;
  padding: 12px 10px 4px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--side-t);
  position: relative;
  cursor: pointer;
}
.nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav a.on {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}
.nav a.on::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--red);
  border-radius: 0 2px 2px 0;
}
.nav a .c {
  margin-left: auto;
  font-size: 11px;
  color: #6e6862;
}
.nav a.muted {
  color: #6e6862;
  cursor: default;
}
.nav a.muted:hover {
  background: none;
  color: #6e6862;
}
.nav a.muted .c {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.side .foot {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11.5px;
  color: #8b847d;
  display: grid;
  gap: 3px;
  flex: none;
}
.side .foot b {
  color: #fff;
  font-weight: 600;
}
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.top {
  height: 52px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.sel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  font-weight: 500;
  cursor: pointer;
  position: relative;
}
.sel small {
  color: var(--t3);
  font-weight: 400;
}
.sel .car {
  color: var(--t3);
  font-size: 10px;
}
.sel.static {
  cursor: default;
}
.env {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #136a43;
  background: #e8f7ef;
  border: 1px solid #cbebd9;
  padding: 3px 8px;
  border-radius: 4px;
}
.env.test {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
}
.search {
  flex: 1;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--t3);
}
.search input {
  border: none;
  background: none;
  outline: none;
  font: inherit;
  color: var(--t1);
  flex: 1;
  min-width: 0;
}
.search kbd {
  margin-left: auto;
}
kbd {
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--t2);
  background: #fff;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
}
.sp {
  flex: 1;
}
.usr {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.usr .av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #2f2b28;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
}
.usr small {
  display: block;
  font-weight: 400;
  color: var(--t3);
  font-size: 11px;
  margin-top: -2px;
}
.usr form {
  margin: 0;
}
.usr .lo {
  border: none;
  background: none;
  color: var(--t3);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 4px;
}
.usr .lo:hover {
  background: var(--bg);
  color: var(--t1);
}
.view {
  padding: 20px 24px 40px;
}
.ph {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.ph h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.ph p {
  color: var(--t3);
  font-size: 12.5px;
}
.ph .r {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  background: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--t1);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg);
}
.btn.pri {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.btn.pri:hover {
  background: var(--red-h);
  border-color: var(--red-h);
}
.btn.dark {
  background: var(--t1);
  border-color: var(--t1);
  color: #fff;
}
.btn.dark:hover {
  background: #2f2b28;
}
.btn kbd {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}
.btn.sm {
  padding: 4px 8px;
  font-size: 12px;
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.inp {
  width: 100%;
  font: inherit;
  font-size: 13px;
  color: var(--t1);
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  padding: 7px 9px;
  outline: none;
}
.inp:focus {
  border-color: var(--t1);
  box-shadow: 0 0 0 3px rgba(27, 25, 23, 0.08);
}
select.inp {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--t3) 50%),
    linear-gradient(135deg, var(--t3) 50%, transparent 50%);
  background-position:
    calc(100% - 13px) 55%,
    calc(100% - 9px) 55%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  padding-right: 24px;
}
label.l {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--t2);
  margin-bottom: 5px;
}
.g {
  display: grid;
  gap: 10px;
}
.g.c2 {
  grid-template-columns: 1fr 1fr;
}
.g.c3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.g.c4 {
  grid-template-columns: repeat(4, 1fr);
}
.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.bar .inp {
  width: auto;
}
.bar .f {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--t2);
  font-size: 12.5px;
}
.bar .f b {
  color: var(--t1);
  font-weight: 500;
}
.bar form {
  display: contents;
}
.per {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  overflow: hidden;
}
.per a {
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--t2);
  border-right: 1px solid var(--line);
  cursor: pointer;
}
.per a:last-child {
  border-right: none;
}
.per a:hover {
  background: var(--bg);
}
.per a.on {
  background: #e8f7ef;
  color: #136a43;
  font-weight: 500;
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.card.pad {
  padding: 16px;
}
table {
  width: 100%;
  border-collapse: collapse;
}
.tablewrap {
  overflow-x: auto;
}
th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--t3);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: #faf9f8;
  white-space: nowrap;
}
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
tbody tr:hover td {
  background: #fbfaf9;
}
tbody tr:last-child td {
  border-bottom: none;
}
.ta-r {
  text-align: right;
}
td.mono {
  font-weight: 500;
  letter-spacing: 0.01em;
}
/* The email envelope: what the mail server did with the KUDE. The colour is
   never alone — the title says it in words. */
.ta-c {
  text-align: center;
}
.mail {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  vertical-align: middle;
}
.mail.ok {
  color: #13794b;
  background: rgba(30, 158, 99, 0.1);
}
.mail.pend {
  color: #a15c07;
  background: rgba(217, 119, 6, 0.12);
}
.mail.rej {
  color: #b5161c;
  background: rgba(224, 30, 37, 0.1);
}
.mail.off {
  color: var(--t3);
  background: rgba(140, 132, 124, 0.12);
}

/* Helper text under a form field. */
small.hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--t3);
  line-height: 1.35;
}
/* A long description is cut with an ellipsis; the full text is in the title. */
td.clip {
  max-width: 340px;
}
td.clip.mails {
  max-width: 240px;
}
td.clip {
  overflow: hidden;
  text-overflow: ellipsis;
}
td .sub {
  display: block;
  font-size: 11.5px;
  color: var(--t3);
  margin-top: 1px;
}
.st {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid transparent;
}
.st::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.st.ok {
  color: #136a43;
  background: #e8f7ef;
  border-color: #cbebd9;
}
.st.pend {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
}
.st.rej {
  color: #9f1239;
  background: #ffe4e6;
  border-color: #fecdd3;
}
.st.off {
  color: var(--t2);
  background: #efedea;
  border-color: #e4e1dd;
}
.tf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  font-size: 12px;
  color: var(--t3);
  border-top: 1px solid var(--line);
}
.pg {
  display: flex;
  gap: 4px;
}
.pg span,
.pg a {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--t2);
}
.pg span.on {
  background: var(--t1);
  color: #fff;
  border-color: var(--t1);
}
.act {
  color: var(--t3);
  cursor: pointer;
  font-size: 16px;
  letter-spacing: 0.1em;
  position: relative;
  user-select: none;
}
.card h3 {
  font-size: 13px;
  font-weight: 600;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card h3 .r {
  margin-left: auto;
  display: flex;
  gap: 6px;
  font-weight: 500;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 13px 16px;
}
.kpi .l2 {
  font-size: 12px;
  color: var(--t3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi .v {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 6px;
}
.kpi .d {
  font-size: 11.5px;
  color: var(--t3);
  margin-top: 4px;
}
.kpi .d b {
  font-weight: 500;
}
.kpi .d.up b {
  color: var(--green);
}
.kpi .d.warn b {
  color: #b45309;
}
.kpi .d.down b {
  color: var(--red);
}
.two {
  display: grid;
  /* minmax(0, …): a long line inside a card wraps instead of widening the
     column past the viewport and dragging the whole page sideways. */
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
/* Atención: its own scroll, and its lines wrap — they are sentences. */
.tablewrap.alerts {
  max-height: 440px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.tablewrap.alerts td {
  white-space: normal;
}
.tablewrap.alerts td .sub {
  overflow-wrap: anywhere;
}
.chart {
  padding: 6px 12px 10px;
}
.chart svg {
  width: 100%;
  height: 170px;
  display: block;
}
.tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px;
}
.tabs a {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--t2);
  cursor: pointer;
}
.tabs a.on {
  background: #fff;
  color: var(--t1);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
/* emitir */
.emit {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}
.form .sec {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.form .sec:last-child {
  border-bottom: none;
}
.form h2 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form h2 span {
  font-weight: 400;
  color: var(--t3);
  font-size: 12px;
  margin-left: auto;
}
/* El estado del cliente vive en el título de la sección: encontrado, nuevo, o
 * completando su ficha. Antes el alta venía en un recuadro amarillo, y parecía
 * que sólo esos campos hacían falta: todo el cartón es del mismo tono. */
.form h2 .est b {
  font-weight: 500;
  color: var(--t2);
}
.form h2 .est.ok i {
  font-style: normal;
  color: var(--green);
  font-weight: 600;
}
/* Lo que aparece cuando el cliente es nuevo o le falta la dirección. */
.more {
  margin-top: 12px;
}
.items td {
  padding: 6px 8px;
}
.items .inp {
  padding: 5px 8px;
}
.items th:first-child,
.items td:first-child {
  padding-left: 12px;
}
.items tbody tr:hover td {
  background: none;
}
.sum {
  position: sticky;
  top: 68px;
}
.sum .ln {
  display: flex;
  justify-content: space-between;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--t2);
}
.sum .ln b {
  color: var(--t1);
  font-weight: 500;
}
.sum .tot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}
.sum .tot span {
  font-size: 12px;
  color: var(--t3);
  font-weight: 500;
}
.sum .tot b {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.sum .meta {
  padding: 10px 14px;
  background: #faf9f8;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--t3);
}
.sum .meta div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.sum .meta span {
  flex: none;
}
.sum .meta b {
  color: var(--t1);
  font-weight: 500;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}
/* The CDC is 44 digits: it gets its own line, in groups of four, inside the card. */
.sum .meta .cdc {
  display: block;
}
.sum .meta .cdc b {
  display: block;
  margin-top: 3px;
  text-align: left;
  font-family: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  word-spacing: 0.15em;
}
.sum .acts {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.sum .acts .btn {
  width: 100%;
  justify-content: center;
  padding: 9px;
}
.note {
  padding: 9px 12px;
  border-radius: 5px;
  background: #e8f7ef;
  border: 1px solid #cbebd9;
  font-size: 12px;
  color: #136a43;
  margin: 0 14px 12px;
}
.res {
  margin-top: 12px;
}
.res dl {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 6px 12px;
  font-size: 13px;
}
.res dt {
  color: var(--t3);
}
.res dd {
  font-weight: 500;
}
.veil {
  position: fixed;
  inset: 0;
  background: rgba(27, 25, 23, 0.45);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}
.dlg {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.dlg h4 {
  font-size: 15px;
  font-weight: 600;
  padding: 16px 18px 6px;
}
.dlg p {
  padding: 0 18px 12px;
  color: var(--t2);
  font-size: 13px;
  line-height: 1.5;
}
.dlg .wrapT {
  margin: 0 18px;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}
.dlg .fo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  gap: 8px;
}
.dlg .fo small {
  color: var(--t3);
  font-size: 11.5px;
}
.dlg .fo .bs {
  display: flex;
  gap: 8px;
}

/* ---- additions beyond the static mockup ---- */
[hidden] {
  display: none !important;
}
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--t3);
  font-size: 13px;
}
.empty b {
  display: block;
  color: var(--t1);
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}
.flash {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.flash.ok {
  color: #136a43;
  background: #e8f7ef;
  border-color: #cbebd9;
}
.flash.err {
  color: #9f1239;
  background: #ffe4e6;
  border-color: #fecdd3;
}
.flash.info {
  color: #1e4620;
  background: #eff6f0;
  border-color: #cbebd9;
}
/* Lo que va a pasar si nadie hace nada: ámbar, ni verde ni rojo. */
.flash.warn {
  color: #92400e;
  background: #fffbeb;
  border-color: #fde68a;
}
.flash a {
  text-decoration: underline;
  font-weight: 500;
}
.menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.25);
  min-width: 150px;
  z-index: 20;
  overflow: hidden;
  text-align: left;
}
.menu a,
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font: inherit;
  font-size: 12.5px;
  color: var(--t1);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.menu a:hover,
.menu button:hover {
  background: var(--bg);
}
.menu .sepd {
  border-top: 1px solid var(--line);
}
.menu form {
  margin: 0;
}
/* login */
.loginwrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--side);
}
.loginbox {
  width: min(380px, 100%);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.5);
  padding: 28px;
}
.loginbox .w {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 26px;
  color: var(--t1);
  letter-spacing: -0.02em;
  text-align: center;
}
.loginbox .w i {
  font-style: normal;
  color: var(--red);
}
.loginbox .sub {
  text-align: center;
  color: var(--t3);
  font-size: 12.5px;
  margin: 4px 0 20px;
}
.loginbox label.l {
  margin-top: 12px;
}
.loginbox .btn {
  width: 100%;
  justify-content: center;
  padding: 10px;
  margin-top: 18px;
}
.loginbox .hint {
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--t3);
  text-align: center;
  line-height: 1.5;
}
.detailgrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
/* item description cell with the 🔍 lupa button */
.desccell {
  display: flex;
  gap: 6px;
  align-items: center;
}
.desccell .inp {
  flex: 1;
  min-width: 0;
}
.desccell [data-lupa] {
  flex: none;
  padding: 5px 8px;
  line-height: 1;
}
/* product search modal results */
#prodResults tr {
  cursor: pointer;
}
#prodResults tr.sel td {
  background: #e8f7ef;
}
#prodResults td.empty {
  color: var(--t3);
  text-align: center;
  padding: 16px;
}
/* configuration switches (real checkboxes) and collapsible sidebar group */
.tg {
  align-items: flex-start;
  cursor: pointer;
}
.tg input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  flex: none;
  accent-color: var(--green);
}
.tg small {
  display: block;
  font-size: 11.5px;
  color: var(--t3);
}
.nav .grp-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
}
.nav .grp-toggle .c {
  margin-left: auto;
  font-size: 11px;
}
.nav .grp {
  display: grid;
  gap: 1px;
}
.pane .fs h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

/* ---- Modelo de factura (KUDE), from the mockup ---- */
.file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #faf9f8;
  margin: 10px 0;
}
.file .ic {
  width: 34px;
  height: 40px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: #fff;
  position: relative;
  flex: none;
}
.file .ic::after {
  content: attr(data-ext);
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  text-align: center;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--t2);
}
.file b {
  font-weight: 500;
}
.file small {
  display: block;
  color: var(--t3);
  font-size: 11.5px;
}
.drop {
  border: 1.5px dashed var(--line-2);
  border-radius: 6px;
  padding: 16px;
  text-align: center;
  color: var(--t3);
  font-size: 12.5px;
  background: #fff;
}
.drop b {
  display: block;
  color: var(--t1);
  font-weight: 500;
  margin-bottom: 3px;
}
.tpl {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 14px;
}
.prev {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}
.prev .l3 {
  font-size: 11.5px;
  color: var(--t3);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}
.sheet {
  background: #fff;
  border: 1px solid var(--line-2);
  aspect-ratio: 1/1.3;
  padding: 14px;
  font-size: 8px;
  color: #222;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.sheet .h {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #999;
  padding-bottom: 6px;
  margin-bottom: 6px;
}
.sheet .h b {
  font-size: 10px;
}
.sheet .box {
  border: 1px solid #999;
  padding: 4px 6px;
  font-size: 7px;
  text-align: center;
}
.sheet table {
  margin-top: 8px;
}
.sheet th,
.sheet td {
  padding: 2px 3px;
  border-bottom: 1px solid #ddd;
  background: none;
  font-size: 7px;
  white-space: normal;
}
.sheet .tt {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  font-weight: 600;
}

/* =========================================================================
 * Vidrio — la capa visual de la aplicación.
 *
 * Superficies de vidrio esmerilado sobre un fondo cálido y vivo. El vidrio sólo
 * se lee como vidrio si hay algo detrás: por eso el fondo lleva dos resplandores
 * de marca (rojo arriba, verde abajo) y un grano muy leve, fijos mientras la
 * página corre por encima. El desenfoque va sólo en superficies grandes (barra,
 * tarjetas, menús): en píldoras y botones sería costo sin efecto.
 *
 * Todo lo de abajo reemplaza reglas de arriba con la misma especificidad; si se
 * borra este bloque, la aplicación vuelve a como estaba.
 * ========================================================================= */

:root {
  /* Texto secundario un punto más oscuro: 4.6:1 sobre el vidrio claro (AA). */
  --t3: #756d66;
  --glass: rgba(255, 255, 255, 0.64);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --glass-soft: rgba(255, 255, 255, 0.46);
  --glass-edge: rgba(27, 25, 23, 0.075);
  --glass-hi: rgba(255, 255, 255, 0.9);
  --glass-blur: blur(18px) saturate(165%);
  --shadow-1: 0 1px 1px rgba(27, 25, 23, 0.03), 0 8px 24px -14px rgba(27, 25, 23, 0.22);
  --shadow-2: 0 1px 2px rgba(27, 25, 23, 0.05), 0 18px 40px -18px rgba(27, 25, 23, 0.32);
  --radius: 14px;
  --radius-sm: 9px;
  --ring: 0 0 0 3px rgba(224, 30, 37, 0.16);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.09 0 0 0 0 0.08 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body {
  background: #efece8;
}

/* ---- el fondo: lo que se ve a través del vidrio ---- */
.main {
  background:
    var(--grain),
    radial-gradient(1100px 520px at 88% -8%, rgba(224, 30, 37, 0.13), transparent 62%),
    radial-gradient(900px 520px at 4% 108%, rgba(30, 158, 99, 0.1), transparent 60%),
    radial-gradient(800px 480px at 46% 38%, rgba(255, 255, 255, 0.7), transparent 72%),
    linear-gradient(180deg, #f4f2ef 0%, #eeebe6 100%);
  background-attachment: fixed;
}

/* ---- la barra de arriba: el contenido pasa por debajo ---- */
.top {
  background: rgba(250, 249, 247, 0.62);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid rgba(27, 25, 23, 0.07);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.55);
  height: 56px;
}
.sel,
.search {
  background: var(--glass-strong);
  border-color: var(--glass-edge);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  transition:
    border-color 0.15s var(--ease),
    box-shadow 0.15s var(--ease);
}
.search:focus-within {
  border-color: rgba(224, 30, 37, 0.45);
  box-shadow: var(--ring);
}
.env {
  border-radius: 999px;
  padding: 3px 10px;
}
.usr .av {
  background: linear-gradient(145deg, #3a3531, #1b1917);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.8),
    0 4px 10px -4px rgba(27, 25, 23, 0.5);
}

/* ---- la barra lateral: oscura, con profundidad ---- */
.side {
  background:
    radial-gradient(420px 260px at 0% 0%, rgba(224, 30, 37, 0.16), transparent 70%),
    linear-gradient(180deg, #1d1b1a 0%, #151413 100%);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.05);
}
.nav a {
  border-radius: 8px;
  transition:
    background 0.15s var(--ease),
    color 0.15s var(--ease);
}
.nav a.on {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.05));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.nav a.on::before {
  box-shadow: 0 0 12px rgba(224, 30, 37, 0.7);
}

/* ---- el encabezado de cada pantalla ---- */
.view {
  padding: 24px 28px 48px;
}
.ph {
  margin-bottom: 18px;
}
.ph h1 {
  font-family: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 32;
}

/* ---- superficies de vidrio ---- */
.card,
.kpi {
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    var(--shadow-1);
}
.card > .tablewrap:first-child,
.card > .tablewrap:first-child table {
  border-radius: var(--radius) var(--radius) 0 0;
}
.card h3 {
  font-size: 13.5px;
  padding: 14px 16px;
  border-bottom-color: var(--glass-edge);
}
.kpi {
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
/* Un brillo arriba: el borde del vidrio que agarra la luz. */
.kpi::after {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 46%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent);
  pointer-events: none;
}
.kpi .v {
  font-family: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  font-size: 27px;
  font-weight: 700;
}

/* ---- tablas ---- */
th {
  background: rgba(250, 249, 247, 0.72);
  border-bottom-color: var(--glass-edge);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 10px 12px;
}
td {
  border-bottom-color: rgba(27, 25, 23, 0.055);
  padding: 10px 12px;
}
/* The customer is the column that grows: it gives way first, with its full
   name in the title, so the table never outgrows its card. */
td.who {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
}
tbody tr {
  transition: background 0.12s var(--ease);
}
tbody tr:hover td {
  background: rgba(224, 30, 37, 0.035);
}
td.mono a,
td.mono {
  font-feature-settings: 'tnum';
}
td.mono a:hover {
  color: var(--red);
}
.tf {
  border-top-color: var(--glass-edge);
  padding: 11px 16px;
}
.pg span,
.pg a {
  border-radius: 7px;
  background: var(--glass-strong);
  border-color: var(--glass-edge);
  transition: background 0.12s var(--ease);
}
.pg a:hover {
  background: #fff;
}

/* ---- píldoras de estado ---- */
.st {
  padding: 3px 9px;
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  backdrop-filter: none;
}
.st.ok {
  background: rgba(30, 158, 99, 0.11);
  border-color: rgba(30, 158, 99, 0.24);
}
.st.pend {
  background: rgba(217, 119, 6, 0.11);
  border-color: rgba(217, 119, 6, 0.26);
}
.st.rej {
  background: rgba(224, 30, 37, 0.09);
  border-color: rgba(224, 30, 37, 0.24);
}
.st.off {
  background: rgba(120, 112, 104, 0.1);
  border-color: rgba(120, 112, 104, 0.2);
}
.st + .st {
  margin-left: 4px;
}

/* ---- botones ---- */
.btn {
  border-radius: var(--radius-sm);
  background: var(--glass-strong);
  border-color: var(--glass-edge);
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    0 1px 2px rgba(27, 25, 23, 0.06);
  transition:
    transform 0.12s var(--ease),
    box-shadow 0.15s var(--ease),
    background 0.15s var(--ease);
}
.btn:hover {
  background: #fff;
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    0 4px 12px -6px rgba(27, 25, 23, 0.3);
}
.btn:active {
  transform: translateY(1px);
}
.btn.pri {
  background: linear-gradient(180deg, #ea2a31 0%, var(--red) 55%, #cc1a20 100%);
  border-color: rgba(150, 16, 22, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 6px 16px -8px rgba(224, 30, 37, 0.75);
}
.btn.pri:hover {
  background: linear-gradient(180deg, #df252c 0%, var(--red-h) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 8px 20px -8px rgba(224, 30, 37, 0.85);
}
.btn.dark {
  background: linear-gradient(180deg, #34302c, var(--t1));
  border-color: #110f0e;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 6px 16px -8px rgba(27, 25, 23, 0.6);
}
.btn:focus-visible,
.nav a:focus-visible,
.per a:focus-visible,
.ctab a:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* ---- campos ---- */
.inp {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(27, 25, 23, 0.14);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  transition:
    border-color 0.15s var(--ease),
    box-shadow 0.15s var(--ease),
    background 0.15s var(--ease);
}
.inp:hover {
  border-color: rgba(27, 25, 23, 0.24);
}
.inp:focus {
  background: #fff;
  border-color: rgba(224, 30, 37, 0.55);
  box-shadow: var(--ring);
}
.inp[readonly] {
  background: rgba(239, 236, 232, 0.6);
  color: var(--t2);
}
label.l {
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ---- la barra de filtros y el período ---- */
.per {
  background: var(--glass-strong);
  border-color: var(--glass-edge);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  padding: 3px;
  gap: 2px;
}
.per a {
  border: none;
  border-radius: 7px;
  transition:
    background 0.15s var(--ease),
    color 0.15s var(--ease);
}
.per a.on {
  background: #fff;
  color: var(--t1);
  box-shadow:
    0 1px 2px rgba(27, 25, 23, 0.1),
    inset 0 0 0 1px rgba(27, 25, 23, 0.06);
  font-weight: 600;
}

/* ---- menú ··· y diálogos: vidrio más denso, flotando ---- */
.menu {
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid var(--glass-edge);
  border-radius: 11px;
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    var(--shadow-2);
  padding: 5px;
}
.menu a,
.menu button {
  border-radius: 7px;
}
.dlg {
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
}
.veil {
  background: rgba(27, 25, 23, 0.34);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

/* ---- avisos ---- */
.flash {
  border-radius: 11px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.note {
  border-radius: 10px;
}
.note.sifen {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.note.sifen b {
  font-size: 10.5px;
  letter-spacing: 0.08em;
}
.note.sifen.ok {
  background: rgba(30, 158, 99, 0.08);
  border-color: rgba(30, 158, 99, 0.22);
  color: #136a43;
}
.note.sifen.rej {
  background: rgba(224, 30, 37, 0.07);
  border-color: rgba(224, 30, 37, 0.22);
  color: #9f1239;
}
.note.sifen.pend {
  background: rgba(217, 119, 6, 0.09);
  border-color: rgba(217, 119, 6, 0.24);
  color: #92400e;
}

/* ---- la factura: el resumen como un comprobante ---- */
.detailgrid {
  gap: 18px;
}
.sum {
  overflow: hidden;
}
.sum .ln {
  padding: 8px 18px;
}
.sum .tot {
  padding: 14px 18px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.15));
  border-top-color: var(--glass-edge);
}
.sum .tot b {
  font-family: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  font-size: 26px;
  font-weight: 700;
}
.sum .meta {
  background: rgba(250, 249, 247, 0.55);
  border-top-color: var(--glass-edge);
  padding: 14px 18px 16px;
  gap: 7px;
}
.sum .meta .cdc b {
  font-family: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 11px;
  color: var(--t2);
  background: rgba(27, 25, 23, 0.04);
  border: 1px solid rgba(27, 25, 23, 0.06);
  border-radius: 7px;
  padding: 6px 8px;
  margin-top: 5px;
}

/* ---- configuración: las pestañas y las secciones (del mockup aprobado) ---- */
.ctab {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--glass-edge);
  background: rgba(250, 249, 247, 0.5);
  border-radius: var(--radius) var(--radius) 0 0;
}
.ctab a {
  padding: 8px 13px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--t2);
  border-radius: 8px;
  position: relative;
  transition:
    background 0.15s var(--ease),
    color 0.15s var(--ease);
}
.ctab a:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--t1);
}
.ctab a.on {
  background: #fff;
  color: var(--t1);
  font-weight: 600;
  box-shadow:
    0 1px 2px rgba(27, 25, 23, 0.1),
    inset 0 0 0 1px rgba(27, 25, 23, 0.06);
}
.ctab a.on::after {
  content: '';
  position: absolute;
  left: 13px;
  right: 13px;
  bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: var(--red);
}
.pane {
  display: none;
  padding: 18px;
}
.pane.on {
  display: grid;
  gap: 14px;
}
/* Cada grupo de ajustes es una lámina de vidrio dentro de la tarjeta. */
.fs {
  background: var(--glass-soft);
  border: 1px solid var(--glass-edge);
  border-radius: 12px;
  padding: 16px 18px 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.fs > h4,
.pane .fs h4 {
  font-family: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 3px;
}
.fs > p {
  font-size: 12.5px;
  color: var(--t3);
  margin-bottom: 14px;
  line-height: 1.45;
}
.fs .g + .g,
.fs .g + div,
.fs > div + .g {
  margin-top: 12px;
}
.fs .btn.pri {
  margin-top: 4px;
}
.warn {
  padding: 10px 13px;
  border-radius: 10px;
  background: rgba(217, 119, 6, 0.09);
  border: 1px solid rgba(217, 119, 6, 0.24);
  color: #92400e;
  font-size: 12.5px;
  line-height: 1.45;
}
.okmsg {
  padding: 10px 13px;
  border-radius: 10px;
  background: rgba(30, 158, 99, 0.08);
  border: 1px solid rgba(30, 158, 99, 0.22);
  color: #136a43;
  font-size: 12.5px;
}

/* ---- interruptores: una casilla de verdad, vestida de switch ---- */
.tg {
  display: flex;
  gap: 12px;
  padding: 10px 2px;
}
/* Only between switches in a list: a lone switch needs no rule above it. */
.tg + .tg {
  border-top: 1px solid rgba(27, 25, 23, 0.05);
}
.tg input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 21px;
  margin: 0;
  border-radius: 999px;
  background: rgba(120, 112, 104, 0.28);
  box-shadow: inset 0 1px 2px rgba(27, 25, 23, 0.18);
  position: relative;
  cursor: pointer;
  transition: background 0.18s var(--ease);
}
.tg input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(27, 25, 23, 0.3);
  transition: transform 0.18s var(--ease);
}
.tg input[type='checkbox']:checked {
  background: linear-gradient(180deg, #25b070, var(--green));
}
.tg input[type='checkbox']:checked::after {
  transform: translateX(15px);
}
.tg input[type='checkbox']:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.tg span {
  font-weight: 500;
  line-height: 1.35;
}
.tg small {
  margin-top: 2px;
  font-weight: 400;
  line-height: 1.4;
}

/* ---- formularios de maestros ---- */
.form .sec {
  padding: 18px 20px;
  border-bottom-color: var(--glass-edge);
}
.form h2 {
  font-family: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  font-weight: 700;
}

/* ---- entrada: una sola coreografía al cargar la pantalla ---- */
@keyframes vidrio-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.view > * {
  animation: vidrio-in 0.32s var(--ease) both;
}
.view > *:nth-child(2) {
  animation-delay: 0.03s;
}
.view > *:nth-child(3) {
  animation-delay: 0.06s;
}
.view > *:nth-child(4) {
  animation-delay: 0.09s;
}
.view > *:nth-child(n + 5) {
  animation-delay: 0.12s;
}
@media (prefers-reduced-motion: reduce) {
  .view > * {
    animation: none;
  }
  .tg input[type='checkbox'],
  .tg input[type='checkbox']::after,
  .btn {
    transition: none;
  }
}

/* Sin desenfoque (navegadores viejos): el vidrio se vuelve casi opaco, legible. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card,
  .kpi,
  .top,
  .menu,
  .dlg {
    background: rgba(255, 255, 255, 0.94);
  }
}

/* ---- la factura: la línea del correo, bajo los ítems ---- */
.detailmain {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}
.mailbar {
  --tint: rgba(120, 112, 104, 0.08);
  --accent: rgba(120, 112, 104, 0.55);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 14px 20px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, var(--tint), transparent 45%), var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    var(--shadow-1);
}
.mailbar::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}
.mailbar.ok {
  --tint: rgba(30, 158, 99, 0.09);
  --accent: linear-gradient(180deg, #2bb877, var(--green));
}
.mailbar.pend {
  --tint: rgba(217, 119, 6, 0.1);
  --accent: #d97706;
}
.mailbar.rej {
  --tint: rgba(224, 30, 37, 0.08);
  --accent: var(--red);
}
.mailbar > .mail {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  flex: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.mailbar-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.mailbar-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--t3);
}
.mailbar-main {
  font-size: 13.5px;
  color: var(--t1);
  overflow-wrap: anywhere;
}
.mailbar-main strong {
  font-weight: 600;
}
.mailbar-main time {
  color: var(--t2);
  font-variant-numeric: tabular-nums;
}
.mailbar small {
  font-size: 12px;
  color: var(--t3);
  overflow-wrap: anywhere;
}
.mailbar > .st {
  flex: none;
}

/* =========================================================================
 * Pantallas angostas: nada empuja la página hacia el costado.
 *
 * Una laptop con la pantalla escalada deja unos 1000 px útiles. A ese ancho la
 * barra de arriba no cabía y corría toda la página 96 px, y las tablas de la
 * configuración — frases y valores largos que no cortaban línea — se salían de
 * su cartón. Acá todo encoge, corta línea o se esconde lo secundario.
 * ========================================================================= */
.top > * {
  min-width: 0;
}
/* El nombre largo se corta con "…" en su etiqueta, no en la caja: la caja no
 * puede recortar, porque su menú cuelga de ella. */
.sel {
  white-space: nowrap;
  max-width: 280px;
  flex-shrink: 1;
}
.sel > .lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.search {
  flex: 1 1 180px;
  min-width: 120px;
}
.env,
.usr {
  flex: none;
  white-space: nowrap;
}
.ph {
  flex-wrap: wrap;
}

/* The action buttons of a row: side by side while they fit, stacked when not. */
td.actions {
  white-space: normal;
}
/* Configuración: frases y valores largos cortan línea dentro de su cartón —
   entre palabras; sólo un código (columna monoespaciada) corta donde haga falta. */
.view[data-area='configuracion'] th,
.view[data-area='configuracion'] td {
  white-space: normal;
  overflow-wrap: break-word;
  vertical-align: top;
}
.view[data-area='configuracion'] td.mono,
.view[data-area='configuracion'] td.anywhere {
  word-break: break-all;
}
.view[data-area='configuracion'] td .st,
.view[data-area='configuracion'] td .btn {
  white-space: nowrap;
}
.view[data-area='configuracion'] td .btn {
  margin: 2px 0;
}
.view[data-area='configuracion'] .card {
  overflow-x: auto;
}

@media (max-width: 1360px) {
  .sel > .lbl small,
  .usr > div,
  .usrlink > div:not(.av) {
    display: none;
  }
}
/* La lista de documentos: el CDC corto y "emitido por" son lo primero que cede. */
@media (max-width: 1480px) {
  th.col-opt,
  td.col-opt {
    display: none;
  }
}
@media (max-width: 1320px) {
  .two {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 1240px) {
  .side {
    width: 208px;
  }
  .view {
    padding: 20px 20px 40px;
  }
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .search kbd {
    display: none;
  }
}
@media (max-width: 1100px) {
  .sel {
    max-width: 170px;
  }
  .env {
    padding: 3px 7px;
    font-size: 10px;
  }
  th.col-ruc,
  td.col-ruc,
  th.hide-narrow,
  td.hide-narrow,
  td > .st[data-migrado] {
    display: none;
  }
  td.who {
    max-width: 170px;
  }
  .detailgrid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- Soporte dentro de una empresa ("Entrar como") ---- */
.supportbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 18px;
  background: repeating-linear-gradient(-45deg, #1c1917, #1c1917 12px, #292524 12px, #292524 24px);
  color: #fafaf9;
  font-size: 12.5px;
  letter-spacing: 0.01em;
}
.supportbar b {
  font-weight: 600;
}
.supportbar form {
  margin: 0 0 0 auto;
}
.supportbar button {
  border: 1px solid rgba(250, 250, 249, 0.35);
  background: transparent;
  color: inherit;
  border-radius: 999px;
  padding: 3px 12px;
  font: inherit;
  cursor: pointer;
}
.supportbar button:hover {
  background: rgba(250, 250, 249, 0.12);
}
.fs.support-only,
.pane .support-only {
  border-left: 3px solid #a8a29e;
  padding-left: 12px;
}
.consolenav {
  display: flex;
  gap: 4px;
  margin-left: 14px;
}
.consolenav a {
  padding: 5px 11px;
  border-radius: 999px;
  color: var(--t2);
  font-size: 13px;
  text-decoration: none;
}
.consolenav a:hover {
  background: rgba(28, 25, 23, 0.06);
  color: var(--t1);
}

/* ---- Varias empresas: la lista de arriba y "Mi cuenta" ---- */
.sel.company .menu button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.sel.company .menu button small {
  color: var(--t3);
  font-size: 11px;
}
.usrlink {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  border-radius: 10px;
  padding: 2px 6px 2px 2px;
}
.usrlink:hover {
  background: rgba(28, 25, 23, 0.05);
}
.membership {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
}
.membership + .membership {
  border-top: 1px dashed rgba(28, 25, 23, 0.1);
}
.membership .off {
  color: var(--t3);
  text-decoration: line-through;
}
.membership form {
  margin: 0;
}
form.inline {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin: 0 0 4px;
}
.inp.sm {
  padding: 4px 8px;
  font-size: 12.5px;
  max-width: 150px;
}
.sel.company .menu {
  left: 0;
  right: auto;
  min-width: 220px;
}

/* ---- Conf. Email: variables y vista previa ---- */
.varchips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.varchips .chip {
  font: 12px/1 var(--mono, 'JetBrains Mono', monospace);
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid var(--glass-edge, rgba(28, 25, 23, 0.12));
  background: rgba(255, 255, 255, 0.7);
  color: var(--t1);
  cursor: pointer;
}
.varchips .chip:hover {
  background: #fff;
  border-color: rgba(28, 25, 23, 0.25);
}
.mailpreview {
  width: 100%;
  min-height: 320px;
  border: 1px solid rgba(28, 25, 23, 0.1);
  border-radius: 12px;
  background: #fff;
}

/* ---- La línea del DE: el código adelante ---- */
.itemrow .inp.mono {
  font-size: 12.5px;
  letter-spacing: -0.01em;
}
.itemrow .inp.nohit {
  border-color: #e11d48;
  background: rgba(225, 29, 72, 0.05);
}

/* ---- Nuevo DE en pantalla angosta: el resumen baja, la línea respira ----
 * Con el resumen al costado, la línea de ítems se apretaba en un portátil de
 * 1280: el código y el precio salían cortados. Hasta 1400 el resumen va abajo y
 * la línea se queda con el ancho entero. */
@media (max-width: 1400px) {
  .emit {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 1240px) {
  .itemrow .inp.mono {
    font-size: 12px;
  }
}

/* ---- Nuevo DE: el documento, en una línea tenue ----
 * Primero el cliente: es por donde empieza el trabajo. El tipo de documento, la
 * condición, la transacción y la moneda casi nunca cambian, así que van abajo,
 * en una franja de un solo renglón: valores en el tono del texto secundario,
 * separados por filetes, sin cajas ni etiquetas. Al pasar el puntero o al
 * enfocar, cada valor toma la misma píldora blanca que los selectores de la
 * barra de arriba — el mismo gesto en toda la aplicación — y se deja cambiar.
 */
.sec.docbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 3px;
  padding: 8px 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.14));
  font-size: 12.5px;
}
.docbar .pick {
  appearance: none;
  -webkit-appearance: none;
  /* Cada valor ocupa lo que mide lo elegido, no lo que mide la opción más larga.
   * Donde el navegador todavía no lo entienda, la línea sale igual de tenue,
   * sólo que más holgada. */
  field-sizing: content;
  max-width: 100%;
  border: 1px solid transparent;
  border-radius: 999px;
  background-color: transparent;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--t3) 50%),
    linear-gradient(135deg, var(--t3) 50%, transparent 50%);
  background-position:
    calc(100% - 13px) 55%,
    calc(100% - 9.5px) 55%;
  background-size: 3.5px 3.5px;
  background-repeat: no-repeat;
  padding: 4px 24px 4px 10px;
  font: inherit;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--t2);
  cursor: pointer;
  transition:
    background-color 0.16s var(--ease),
    border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease),
    color 0.16s var(--ease);
}
.docbar .pick:hover {
  color: var(--t1);
  border-color: var(--glass-edge);
  background-color: var(--glass-strong);
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    0 1px 2px rgba(27, 25, 23, 0.04);
}
.docbar .pick:focus {
  outline: none;
  color: var(--t1);
  border-color: rgba(224, 30, 37, 0.45);
  background-color: #fff;
  box-shadow: var(--ring);
}
/* Filete entre valor y valor: separa sin pesar. */
.docbar .sep {
  width: 1px;
  height: 13px;
  margin: 0 5px;
  background: rgba(27, 25, 23, 0.13);
}
.docbar .cur {
  padding: 4px 2px;
  color: var(--t3);
  letter-spacing: 0.03em;
}

/* ---- Reenviar el correo, dentro de su propia barra ----
 * Va antes de la etiqueta de estado: el campo es opcional (vacío = al cliente)
 * y en pantalla angosta pasa abajo, con la barra entera en dos líneas. */
.mailbar-resend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.mailbar-resend .inp.sm {
  width: 200px;
}
@media (max-width: 900px) {
  .mailbar {
    flex-wrap: wrap;
  }
  .mailbar-resend {
    margin-left: 0;
    width: 100%;
  }
  .mailbar-resend .inp.sm {
    flex: 1;
    width: auto;
  }
}
