/* Packify Admin — hoja de estilos única, sin paso de compilación.
   Colores de marca: azul marino #303E51, verde #75C900, blanco, gris azulado #E3EAF2. */

@font-face { font-family: "Lexend"; src: url("../fonts/Lexend-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Lexend"; src: url("../fonts/Lexend-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Lexend"; src: url("../fonts/Lexend-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --navy: #303E51;
  --navy-900: #222D3B;
  --navy-700: #3D4E66;
  --green: #75C900;
  --green-700: #4F8A00;   /* verde legible sobre blanco */
  --mist: #E3EAF2;
  --mist-50: #F4F7FA;
  --paper: #FFFFFF;
  --kraft: #B98E5E;       /* tono papel kraft, solo para acentos de estado "pendiente" */
  --ink: #1F2935;
  --muted: #5D6B7E;
  --line: #D3DCE7;
  --danger: #B42318;
  --danger-bg: #FDECEA;
  --warn-bg: #FBF3E8;
  --ok-bg: #EEF8E0;
  --radius-sm: 6px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(48, 62, 81, .08), 0 4px 14px rgba(48, 62, 81, .06);
  --sidebar: 248px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Lexend", system-ui, sans-serif;
  color: var(--ink);
  background: var(--mist);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); text-underline-offset: 3px; }
a:hover { color: var(--green-700); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { color: var(--navy); line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; max-width: 72ch; }
small, .muted { color: var(--muted); }
.muted { font-size: .9rem; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--navy);
  color: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 1.5rem 1rem 1rem;
}
.sidebar .brand { padding: 0 .5rem 1.5rem; }
.sidebar .brand img { width: 150px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-group { margin: 1.25rem .75rem .35rem; font-size: .75rem; color: #9FB0C6; font-weight: 600; }
.nav a, .nav .soon {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .75rem; border-radius: var(--radius-sm);
  color: #E3EAF2; text-decoration: none; font-size: .95rem;
}
.nav a:hover { background: var(--navy-700); color: #fff; }
.nav a[aria-current="page"] { background: var(--paper); color: var(--navy); font-weight: 600; }
.nav a[aria-current="page"] svg { color: var(--green-700); }
.nav .soon { color: #7F90A8; cursor: default; }
.nav .soon span.tag { margin-left: auto; white-space: nowrap; font-size: .7rem; border: 1px solid #5B6C84; border-radius: 99px; padding: 0 .45rem; }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .me { border-top: 1px solid var(--navy-700); padding: 1rem .5rem 0; font-size: .85rem; }
.sidebar .me strong { display: block; color: #fff; font-weight: 600; }
.sidebar .me span { color: #9FB0C6; }
.sidebar .me form { margin-top: .5rem; }
.sidebar .me button { background: none; border: 0; padding: 0; color: #E3EAF2; font: inherit; text-decoration: underline; cursor: pointer; }

.main { min-width: 0; padding: 2rem clamp(1rem, 3vw, 2.5rem) 3rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head p { margin: 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.topbar { display: none; }

/* ---------- Superficies ---------- */
.panel { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; }
.panel > h2:first-child { margin-bottom: 1rem; }
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* Indicadores: el número manda; la etiqueta va debajo, en minúsculas. */
.stat { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.5rem; border-top: 4px solid var(--navy); }
.stat .value { font-size: 1.9rem; font-weight: 700; color: var(--navy); line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .9rem; }
.stat.is-ok { border-top-color: var(--green); }
.stat.is-warn { border-top-color: var(--kraft); }

/* ---------- Tablas (encabezado azul marino, como la cotización PDF) ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--paper); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
thead th {
  background: var(--navy); color: #fff; text-align: left; font-weight: 600;
  padding: .7rem 1rem; white-space: nowrap;
}
tbody td { padding: .7rem 1rem; border-bottom: 1px solid var(--mist); vertical-align: top; }
tbody tr:nth-child(even) td { background: var(--mist-50); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { display: block; color: var(--muted); font-size: .82rem; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* ---------- Etiquetas de estado ---------- */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--green-700); }
.badge-off { background: var(--mist); color: var(--muted); }
.badge-warn { background: var(--warn-bg); color: #8A5A22; }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-navy { background: var(--navy); color: #fff; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; font-size: .92rem;
  padding: .6rem 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn-primary { background: var(--green); color: var(--navy-900); }
.btn-primary:hover { background: #82DA0A; color: var(--navy-900); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-900); color: #fff; }
.btn-ghost { background: var(--paper); color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn-danger { background: var(--paper); color: var(--danger); border-color: #F1B8B2; }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--navy); text-decoration: underline; cursor: pointer; }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 1.1rem; max-width: 640px; }
.form-row { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field label, .label { display: block; font-weight: 600; font-size: .88rem; color: var(--navy); margin-bottom: .3rem; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: .25rem; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: .6rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(117, 201, 0, .35); }
input.is-invalid, select.is-invalid { border-color: var(--danger); }
.error { color: var(--danger); font-size: .85rem; margin-top: .25rem; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-size: .92rem; }
.check input { margin-top: .25rem; accent-color: var(--green-700); width: 16px; height: 16px; }
.code-input { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { min-width: 160px; }
.filters .field label { font-size: .8rem; }

/* ---------- Avisos ---------- */
.alert { padding: .85rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem; font-size: .93rem; border-left: 4px solid; }
.alert-ok { background: var(--ok-bg); border-color: var(--green); }
.alert-warn { background: var(--warn-bg); border-color: var(--kraft); }
.alert-danger { background: var(--danger-bg); border-color: var(--danger); }
.alert ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.secret-box { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; }
.secret-box code { font-size: 1.3rem; letter-spacing: .05em; background: rgba(255,255,255,.12); padding: .2rem .55rem; border-radius: 4px; }
.secret-box p { color: #E3EAF2; }

/* ---------- Permisos por módulo ---------- */
.perm-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; }
.perm-group h3 { margin-bottom: .6rem; }
.perm-group .check { margin-bottom: .45rem; }
.perm-list { display: flex; flex-wrap: wrap; gap: .35rem; }

/* ---------- Pantallas de acceso ---------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  background: var(--paper);
}
.auth-art {
  background: var(--navy); color: #fff; padding: clamp(2rem, 5vw, 4rem);
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-art img { width: 180px; }
/* Trazo de bolsa con fuelle: el único gesto gráfico del sistema. */
.auth-art .bag { position: absolute; right: -40px; bottom: -30px; width: min(420px, 70%); opacity: .95; }
.auth-art p { color: #C9D5E3; max-width: 30ch; font-size: 1.05rem; position: relative; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card .form { max-width: none; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; width: max-content; margin: 0 auto 1rem; }
.qr svg { display: block; width: 200px; height: 200px; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem .75rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1rem; background: var(--mist-50); border: 1px dashed var(--line); padding: 1rem; border-radius: var(--radius); }
.steps { padding-left: 1.2rem; margin: 0 0 1.25rem; }
.steps li { margin-bottom: .4rem; }

.pagination { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: 1rem; }
.pagination a, .pagination span { padding: .35rem .7rem; border-radius: var(--radius-sm); background: var(--paper); border: 1px solid var(--line); text-decoration: none; font-size: .85rem; }
.pagination .active { background: var(--navy); color: #fff; border-color: var(--navy); }
.pagination .disabled { color: var(--muted); }


/* ---------- CRM: fichas, historial y embudo ---------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; font-size: .92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.client-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; color: var(--muted); font-size: .92rem; }
.client-head a { color: var(--navy); }
.cols { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: start; }
.stage-dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .35rem; vertical-align: baseline; }
.stage-pill { display: inline-flex; align-items: center; gap: .1rem; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--mist-50); border: 1px solid var(--line); color: var(--navy); white-space: nowrap; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 34px 1fr; gap: .75rem; padding: .85rem 0; border-bottom: 1px solid var(--mist); }
.timeline li:last-child { border-bottom: 0; }
.timeline .ico { width: 34px; height: 34px; border-radius: 50%; background: var(--mist); color: var(--navy); display: grid; place-items: center; }
.timeline .ico svg { width: 17px; height: 17px; }
.timeline .ico.in { background: var(--ok-bg); color: var(--green-700); }
.timeline .ico.sys { background: var(--mist-50); color: var(--muted); }
.timeline .meta { font-size: .8rem; color: var(--muted); }
.timeline .body { white-space: pre-line; font-size: .92rem; margin-top: .25rem; overflow-wrap: anywhere; max-height: 18rem; overflow: auto; }
.timeline h3 { font-size: .95rem; margin: 0; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: start; }
.board-col { background: var(--mist-50); border-radius: var(--radius); border: 1px solid var(--line); display: flex; flex-direction: column; max-height: calc(100vh - 220px); min-height: 160px; }
.board-col header { padding: .75rem .9rem; border-top: 4px solid var(--navy); border-radius: var(--radius) var(--radius) 0 0; background: var(--paper); display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.board-col header h2 { font-size: .95rem; margin: 0; }
.board-col header small { white-space: nowrap; }
.board-col .cards { padding: .6rem; display: flex; flex-direction: column; gap: .6rem; overflow-y: auto; flex: 1; min-height: 60px; }
.board-col.drop .cards { background: var(--ok-bg); outline: 2px dashed var(--green); outline-offset: -4px; border-radius: 0 0 var(--radius) var(--radius); }
.card { background: var(--paper); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: .7rem .8rem; font-size: .88rem; cursor: grab; border-left: 3px solid transparent; }
.card.dragging { opacity: .5; }
.card a.title { font-weight: 600; color: var(--navy); text-decoration: none; display: block; line-height: 1.3; }
.card a.title:hover { text-decoration: underline; }
.card .client { color: var(--ink); margin-top: .15rem; }
.card .foot { display: flex; justify-content: space-between; gap: .5rem; align-items: center; margin-top: .45rem; color: var(--muted); font-size: .78rem; }
.card .amount { font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; }
.card select { margin-top: .5rem; padding: .3rem .4rem; font-size: .8rem; display: none; }
.card.is-new { border-left-color: var(--green); }

.copy-field { display: flex; gap: .5rem; }
.copy-field input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.channel { display: grid; grid-template-columns: 40px 1fr; gap: 1rem; }
.channel .ico { width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--mist); display: grid; place-items: center; color: var(--navy); }
.channel .ico svg { width: 20px; height: 20px; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.inline-form .field { flex: 1 1 160px; }
details.more summary { cursor: pointer; color: var(--navy); font-weight: 600; font-size: .9rem; margin: .5rem 0; }
.color-input { width: 3rem !important; padding: .2rem !important; height: 2.4rem; }

@media (max-width: 900px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .board { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: 1fr; }
  .board-col { max-height: none; }
  .card { cursor: default; }
  .card select { display: block; width: 100%; }
}

/* ---------- Celular ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--navy); padding: .75rem 1rem; position: sticky; top: 0; z-index: 30;
  }
  .topbar img { width: 120px; }
  .topbar button { background: none; border: 1px solid #5B6C84; color: #fff; border-radius: var(--radius-sm); padding: .4rem .6rem; font: inherit; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 23, 33, .45); }
  .main { padding: 1.25rem 1rem 2.5rem; }
  h1 { font-size: 1.45rem; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { min-height: 0; padding: 1.5rem; }
  .auth-art .bag, .auth-art p { display: none; }
  /* Tablas como tarjetas en pantallas angostas */
  table.stack thead { display: none; }
  table.stack tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
  table.stack td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .3rem 1rem; background: none !important; text-align: right; }
  table.stack td::before { content: attr(data-label); font-weight: 600; color: var(--navy); text-align: left; }
  table.stack td.num { text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Cotizaciones ---------- */
.calc { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.calc-main .panel h2 { margin-bottom: .75rem; }
.calc-side { position: sticky; top: 1rem; }
.calc-result .price { font-size: 2.2rem; font-weight: 700; color: var(--navy); line-height: 1.1; margin-bottom: .75rem; font-variant-numeric: tabular-nums; }
.calc-result .price small { display: block; font-size: .8rem; font-weight: 400; color: var(--muted); }
.breakdown { width: 100%; border-collapse: collapse; font-size: .86rem; margin-top: .75rem; }
.breakdown td { padding: .3rem .2rem; border-bottom: 1px solid var(--mist); }
.breakdown td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.breakdown tr.strong td { font-weight: 700; color: var(--navy); }
.totals { display: grid; grid-template-columns: max-content max-content; gap: .3rem 1.5rem; justify-content: end; margin: 1rem 0 0; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--muted); text-align: right; }
.totals dd { margin: 0; text-align: right; }
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.tabs a { padding: .45rem .9rem; border-radius: 99px; border: 1px solid var(--line); background: var(--paper); text-decoration: none; color: var(--navy); font-size: .9rem; }
.tabs a[aria-current] { background: var(--navy); color: #fff; border-color: var(--navy); }
.pair { display: flex; gap: .35rem; align-items: center; }
.pair input { max-width: 6rem; }
.rules-grid { display: grid; gap: 1rem 1.25rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
@media (max-width: 900px) {
  .calc { grid-template-columns: 1fr; }
  .calc-side { position: static; }
}
.row-actions { display: flex; gap: .6rem; margin-top: .35rem; font-size: .8rem; }
.row-actions form { display: inline; }
.link-btn.danger { color: var(--danger); }
.price-bar { display: none; }
@media (max-width: 900px) {
  .price-bar { display: flex; position: sticky; bottom: 0; z-index: 5; justify-content: space-between; align-items: center; gap: 1rem;
    background: var(--navy); color: #fff; padding: .7rem 1rem; margin: 0 -1rem; box-shadow: 0 -4px 12px rgba(0,0,0,.15); }
  .price-bar strong { font-size: 1.4rem; display: block; line-height: 1.1; }
  .price-bar small { color: #C9D5E3; font-size: .78rem; }
}
td.neg { color: var(--danger); }
tr.overdue td { color: var(--danger); }
tr.total-row td { border-top: 2px solid var(--navy); }
.mv-form { margin-top: .75rem; }
@media (max-width: 640px) {
  .mv-rows tr { display: grid; grid-template-columns: auto 1fr auto; gap: .15rem .5rem; padding: .5rem 0; border-bottom: 1px solid var(--mist); }
  .mv-rows td { border: 0; padding: 0; }
  .mv-rows td:nth-child(2) { grid-column: 1 / -1; grid-row: 1; }
  .mv-rows td.num:last-child { grid-column: 1 / -1; text-align: left; }
}
@media (max-width: 640px) {
  .dl { grid-template-columns: minmax(0, 1fr) auto; }
  .dl dd { overflow-wrap: normal; white-space: nowrap; }
}
.dl dt .sub { display: block; font-size: .8rem; }
