/* =========================================================================
   Documentos · sólo importados córdoba — panel "acero sage"
   Acero casi negro + un único acento verde-salvia (SOP Global, #8DA893).
   Instrumento de trabajo: calmo, legible al sol, estructura tipo placa.
   ========================================================================= */

:root {
  /* Superficies de acero — elevación whisper-quiet */
  --bg: oklch(0.145 0 0);
  --panel: oklch(0.186 0 0);
  --raised: oklch(0.225 0 0);          /* dropdowns/popovers */
  --input: oklch(0.132 0 0);           /* inset: más oscuro que el entorno */

  /* Jerarquía de texto (4 niveles) */
  --ink: oklch(0.965 0 0);
  --ink-2: oklch(0.785 0 0);
  --ink-3: oklch(0.635 0 0);
  --ink-faint: oklch(0.545 0 0);       /* disabled / notas (opcional) */
  --placeholder: oklch(0.40 0 0);      /* ejemplos en inputs — apenas insinuados */

  /* Acento salvia (SOP Global) — único, usado con intención */
  --accent: oklch(0.705 0.039 152);
  --accent-bright: oklch(0.775 0.046 152);
  --accent-ink: oklch(0.17 0.012 152); /* texto OSCURO sobre el salvia */
  --accent-tint: oklch(0.705 0.039 152 / 0.15);

  /* Bordes — progresión */
  --line: oklch(1 0 0 / 0.10);
  --line-soft: oklch(1 0 0 / 0.055);
  --line-strong: oklch(1 0 0 / 0.18);

  --danger: oklch(0.68 0.16 25);
  --photo-outline: rgba(255, 255, 255, 0.1);

  --font: "Barlow", system-ui, -apple-system, sans-serif;
  --font-cond: "Barlow Condensed", "Arial Narrow", sans-serif;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --r-input: 10px;
  --r-panel: 14px;
  --r-chip: 8px;

  --z-header: 10;
  --z-dropdown: 30;
  --z-scrim: 40;
  --z-toast: 50;

  --tap: 46px;
  --wrap: 540px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
[x-cloak] { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
img { display: block; max-width: 100%; }

/* Etiqueta estampada (voz de marca: condensada, mayúsculas, tracking) */
.label {
  font-family: var(--font-cond); font-weight: 600; font-size: 0.82rem;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3);
}

.wrap { max-width: var(--wrap); margin-inline: auto; padding: 16px; }

/* ----------------------------- App bar ----------------------------- */
.appbar {
  position: sticky; top: 0; z-index: var(--z-header);
  background: var(--bg); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; min-height: 60px;
}
.appbar-actions { display: flex; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-plate {
  background: #fff; border-radius: var(--r-chip); padding: 7px 11px;
  display: flex; align-items: center; outline: 1px solid var(--photo-outline); outline-offset: -1px;
}
.brand-plate img { height: 22px; width: auto; }
.brand-sub { font-family: var(--font-cond); font-weight: 600; font-size: 0.95rem;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; min-height: 52px; padding: 14px 20px;
  font-family: var(--font-cond); font-weight: 700; font-size: 1.14rem;
  letter-spacing: 0.045em; text-transform: uppercase;
  border: 0; border-radius: var(--r-input); cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  transition: background-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--accent-bright); }
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: .55; transform: none; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; width: auto; padding: 8px 14px; white-space: nowrap;
  font-family: var(--font); font-weight: 600; font-size: 0.94rem; letter-spacing: 0.01em;
  text-transform: none; background: none; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--r-chip); cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn-ghost:hover { background: var(--accent-tint); color: var(--ink); border-color: var(--accent); }
.btn-ghost:active { transform: scale(0.97); }
.ico { width: 18px; height: 18px; flex: none; }

/* ----------------------------- Login ----------------------------- */
.login-screen {
  position: relative; overflow: hidden;
  min-height: 100dvh; display: grid; place-items: center; padding: 22px;
  /* resplandor salvia detrás de la tarjeta + leve viñeta */
  background:
    radial-gradient(64% 52% at 50% 40%, oklch(0.705 0.05 152 / 0.11), transparent 72%),
    radial-gradient(135% 120% at 50% 46%, transparent 58%, oklch(0.105 0 0) 100%),
    var(--bg);
}
/* red de nodos conectados (conexiones globales) — visible alrededor, atenuada tras la tarjeta */
.login-screen::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: url("/assets/login-net.svg") center center / cover no-repeat;
  -webkit-mask-image: radial-gradient(ellipse 64% 54% at 50% 44%, transparent 20%, #000 70%);
          mask-image: radial-gradient(ellipse 64% 54% at 50% 44%, transparent 20%, #000 70%);
}
.login-card { position: relative; z-index: 1; width: 100%; max-width: 380px; }
.login-head { text-align: center; margin-bottom: 26px; }
.login-head .brand-plate { display: inline-flex; margin-bottom: 18px; padding: 12px 18px; }
.login-head .brand-plate img { height: 40px; }
@media (min-width: 880px) {
  .login-head .brand-plate { padding: 16px 24px; }
  .login-head .brand-plate img { height: 56px; }
}
.login-head h1 { font-family: var(--font-cond); font-weight: 700; font-size: 1.5rem;
  letter-spacing: 0.04em; text-transform: uppercase; margin: 0; }
.login-head p { color: var(--ink-3); margin: 4px 0 0; font-size: 0.9rem; }

/* ----------------------------- Card ----------------------------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 18px; }

/* ----------------------------- Tabs ----------------------------- */
.tabs { display: flex; gap: 4px; background: var(--input); border: 1px solid var(--line-soft);
  border-radius: var(--r-chip); padding: 4px; margin: 16px 0; }
.tabs button {
  flex: 1; min-height: 44px; border: 0; background: none; border-radius: 6px;
  font-family: var(--font-cond); font-weight: 600; font-size: 1.02rem; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--ink-3); cursor: pointer;
  transition: color .15s var(--ease), background-color .15s var(--ease);
}
.tabs button.active { background: var(--accent-tint); color: var(--accent-bright); box-shadow: inset 0 0 0 1px var(--accent); }

/* ----------------------------- Fields ----------------------------- */
.field { margin-bottom: 16px; }
.field > .label { display: block; margin-bottom: 7px; }
.hint { color: var(--ink-3); font-size: 0.8rem; margin-top: 6px; }

input, textarea {
  width: 100%; min-height: var(--tap); padding: 11px 13px; font: inherit; color: var(--ink);
  background: var(--input); border: 1px solid var(--line); border-radius: var(--r-input);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
/* Campo de contraseña con botón de ojo */
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 48px; }
.pass-toggle {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 0; background: none; color: var(--ink-3); cursor: pointer; border-radius: 8px;
  transition: color .15s var(--ease), background-color .15s var(--ease);
}
.pass-toggle:hover { color: var(--ink); background: var(--accent-tint); }
.pass-toggle svg { width: 20px; height: 20px; }
/* iOS renderiza date distinto: lo forzamos a comportarse como un input común */
input[type="date"] { -webkit-appearance: none; appearance: none; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* Segmented (tipo de documento) */
.seg { display: flex; gap: 4px; background: var(--input); border: 1px solid var(--line-soft);
  border-radius: var(--r-chip); padding: 4px; }
.seg button {
  flex: 1; min-height: 46px; border: 0; background: none; border-radius: 6px;
  font-family: var(--font-cond); font-weight: 600; font-size: 1.08rem; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--ink-3); cursor: pointer;
  transition: color .15s var(--ease), background-color .15s var(--ease), box-shadow .15s var(--ease);
}
.seg button.active { background: var(--accent-tint); color: var(--accent-bright); box-shadow: inset 0 0 0 1px var(--accent); }
.seg-pay button { font-size: 0.96rem; letter-spacing: 0.02em; }

/* Membrete: selección de logo */
.logo-select { display: flex; gap: 10px; }
.logo-select button {
  flex: 1; min-height: 62px; padding: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: var(--input); border: 1px solid var(--line); border-radius: var(--r-input);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.logo-select button.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.logo-chip {
  background: #fff; border-radius: 6px; padding: 7px 11px; display: flex; align-items: center;
  outline: 1px solid var(--photo-outline); outline-offset: -1px;
}
.logo-chip img { height: 22px; width: auto; max-width: 100%; display: block; }

/* Moneda: segmented chico */
.money { display: flex; gap: 4px; min-height: var(--tap); background: var(--input); border: 1px solid var(--line-soft);
  border-radius: var(--r-chip); padding: 4px; }
.money button { flex: 1; min-height: 0; border: 0; background: none; border-radius: 6px;
  font: inherit; font-weight: 600; color: var(--ink-3); cursor: pointer; transition: .15s var(--ease); }
.money button.active { background: var(--accent-tint); color: var(--accent-bright); box-shadow: inset 0 0 0 1px var(--accent); }

/* Autocomplete */
.ac { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: var(--z-dropdown);
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-input);
  box-shadow: 0 14px 34px rgba(0,0,0,.55); max-height: 240px; overflow: auto;
}
.ac-list button {
  display: block; width: 100%; text-align: left; min-height: 46px; padding: 10px 13px;
  border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer;
  border-bottom: 1px solid var(--line-soft); transition: background-color .12s var(--ease);
}
.ac-list button:last-child { border-bottom: 0; }
.ac-list button:hover { background: var(--accent-tint); }
.ac-list .muted { color: var(--ink-3); }

/* Cliente elegido */
.chip {
  display: inline-flex; align-items: center; gap: 12px; min-height: var(--tap);
  background: var(--input); border: 1px solid var(--line); border-radius: var(--r-chip); padding: 8px 8px 8px 14px;
}
.chip strong { font-weight: 600; }
.chip .chip-tax { color: var(--ink-3); font-size: 0.85rem; }
.chip button { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 1.3rem;
  line-height: 1; width: 30px; height: 30px; border-radius: 6px; transition: .12s; }
.chip button:hover { background: var(--line); color: var(--ink); }

/* Cliente nuevo inline */
.new-client { background: var(--input); border: 1px solid var(--line-soft); border-radius: var(--r-input);
  padding: 14px; margin-top: 10px; }
.new-client input { background: var(--bg); }

/* Fotos */
.thumbs { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 10px; }
.thumb { position: relative; width: 78px; height: 78px; border-radius: var(--r-chip); overflow: hidden;
  outline: 1px solid var(--photo-outline); outline-offset: -1px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border: 0;
  border-radius: 50%; background: rgba(0,0,0,.7); color: #fff; cursor: pointer; line-height: 1; font-size: .95rem; }
.add-photo {
  width: 78px; height: 78px; border-radius: var(--r-chip); border: 1px dashed var(--line-strong);
  background: var(--input); color: var(--ink-3); display: grid; place-items: center; cursor: pointer;
  transition: border-color .15s var(--ease), color .15s var(--ease), background-color .15s var(--ease);
}
.add-photo:hover { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-tint); }
.add-photo svg { width: 26px; height: 26px; }
.file-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Número estampado (signature) */
.stamp {
  display: flex; align-items: baseline; gap: 10px; margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.stamp .label { color: var(--ink-3); }
.stamp .num {
  font-family: var(--font-cond); font-weight: 700; font-size: 1.5rem; letter-spacing: 0.02em;
  color: var(--ink); font-variant-numeric: tabular-nums;
  border-bottom: 2px solid var(--accent); padding-bottom: 1px;
}

.generate-wrap { margin-top: 18px; }
.error { color: var(--danger); font-size: 0.86rem; margin-top: 10px; }

/* ----------------------------- Historial ----------------------------- */
.doc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 2px; border-bottom: 1px solid var(--line-soft); }
.doc-row:last-child { border-bottom: 0; }
.doc-num { font-family: var(--font-cond); font-weight: 700; font-size: 1.1rem; letter-spacing: 0.02em; }
.doc-meta { color: var(--ink-3); font-size: 0.86rem; margin-top: 2px; }
.doc-meta .amt { color: var(--ink-2); }
.doc-actions { display: flex; gap: 8px; flex: none; }
.empty { color: var(--ink-3); padding: 16px 2px; }

/* ----------------------------- Modal: firma ----------------------------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: var(--z-scrim);
  background: oklch(0 0 0 / 0.62); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 460px; background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: var(--r-panel);
  padding: 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 {
  font-family: var(--font-cond); font-weight: 700; font-size: 1.3rem;
  letter-spacing: 0.04em; text-transform: uppercase; margin: 0;
}
.modal-x {
  border: 0; background: none; color: var(--ink-3); font-size: 1.7rem; line-height: 1;
  width: 40px; height: 40px; border-radius: var(--r-chip); cursor: pointer;
  display: grid; place-items: center;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.modal-x:hover { background: var(--line); color: var(--ink); }
.modal-sub { color: var(--ink-3); font-size: 0.88rem; margin: 8px 0 16px; line-height: 1.45; }
.sigpad-wrap { background: #fff; border-radius: 10px; padding: 6px;
  outline: 1px solid var(--photo-outline); outline-offset: -1px; }
.sigpad { display: block; width: 100%; height: 200px; border-radius: 6px;
  touch-action: none; cursor: crosshair; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 16px; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.modal-foot .hint { margin: 0; }
.link-danger {
  border: 0; background: none; color: var(--danger); font: inherit; font-size: 0.85rem;
  cursor: pointer; padding: 4px 0; flex: none;
  text-decoration: underline; text-underline-offset: 3px;
}
.link-danger:hover { color: oklch(0.74 0.16 25); }
.link-danger[disabled] { opacity: .5; cursor: default; }

/* ----------------------------- Layout ----------------------------- */
.panel-title {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-family: var(--font-cond); font-weight: 700; font-size: 1.06rem;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft);
}
.link-accent {
  border: 0; background: none; color: var(--accent-bright); cursor: pointer;
  font-family: var(--font); font-weight: 600; font-size: 0.82rem; letter-spacing: 0;
  text-transform: none; padding: 4px 2px;
}
.link-accent:hover { text-decoration: underline; text-underline-offset: 3px; }

.panel-recent { margin-top: 16px; }

/* Paginación del historial */
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft);
}
.pager .btn-ghost { flex: none; }
.pager-info { color: var(--ink-3); font-size: 0.86rem; font-variant-numeric: tabular-nums; }

/* Mobile/tablet compacto: sin "Documentos" en el header (deja sitio a los botones) */
@media (max-width: 879px) {
  .brand-sub { display: none; }
}
/* Teléfono: apilamos las filas con texto largo para que el placeholder entre completo */
@media (max-width: 600px) {
  .row-stack { flex-direction: column; gap: 0; }
}

/* Desktop: "Nuevo" aprovecha el ancho — formulario ancho + rail de últimos */
@media (min-width: 880px) {
  .wrap { max-width: 1120px; }
  .screen-nuevo {
    display: grid; grid-template-columns: minmax(0, 1.62fr) minmax(300px, 0.92fr);
    gap: 22px; align-items: start;
  }
  .screen-hist { max-width: 760px; margin-inline: auto; }
  .panel-recent { margin-top: 0; position: sticky; top: 84px; }

  /* Tipo + Membrete lado a lado */
  .form-head { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; margin-bottom: 16px; }
  .form-head > .field { margin-bottom: 0; }
}

/* ----------------------------- Motion ----------------------------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .btn:active, .btn-ghost:active { transform: none; }
}
