/* ATRYASOL — sistema visual común (CRM y app de clientes). Identidad de atryasol.com */
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 400; font-display: swap; src: url("/comun/fuentes/poppins-400.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 500; font-display: swap; src: url("/comun/fuentes/poppins-500.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap; src: url("/comun/fuentes/poppins-600.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: swap; src: url("/comun/fuentes/poppins-700.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 800; font-display: swap; src: url("/comun/fuentes/poppins-800.woff2") format("woff2"); }
:root {
  --bg: #F9FAFD;
  --surface: #ffffff;
  --surface-2: #F0F2F5;
  --surface-3: #E6E9F0;
  --border: #E4E7EE;
  --border-strong: #CBD1DC;
  --text: #1a1a2e;
  --text-2: #3d4157;
  --muted: #6b7084;
  --brand: #F5A623;
  --brand-hover: #FFB627;
  --brand-soft: #FEF3DC;
  --brand-ink: #0a1628;
  --brand-text: #B45F06;
  --navy: #0a1628;
  --navy-2: #050a14;
  --accent: #E85800;
  --accent-soft: #FDE8DA;
  --accent-ink: #B54400;
  --ok: #23824f;
  --ok-soft: #e0f2e7;
  --warn: #a8640a;
  --warn-soft: #fcecd1;
  --bad: #c0392b;
  --bad-soft: #fbe3e0;
  --info: #2a62a6;
  --info-soft: #e2ecf8;
  --violet: #6d4bc2;
  --violet-soft: #ece6fa;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, .05);
  --shadow: 0 1px 2px rgba(16, 24, 20, .04), 0 6px 20px -6px rgba(16, 24, 20, .10);
  --shadow-lg: 0 24px 60px -12px rgba(16, 24, 20, .28);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #050a14; --surface: #0d1a2e; --surface-2: #13233b; --surface-3: #1a2d49;
    --border: #1d2d48; --border-strong: #2a3d5c;
    --text: #F1F3F8; --text-2: #c5cbd8; --muted: #8b93a7;
    --brand: #F5A623; --brand-hover: #FFB627; --brand-soft: #2a2312; --brand-ink: #0a1628; --brand-text: #F5A623;
    --accent: #FF7A2E; --accent-soft: #3a2010; --accent-ink: #FF9A5C;
    --ok: #5cc98b; --ok-soft: #15301f; --warn: #eaa64a; --warn-soft: #362812;
    --bad: #f07b6e; --bad-soft: #3a1c19; --info: #7fb0ea; --info-soft: #172a40;
    --violet: #b29cf0; --violet-soft: #271f3d;
    --shadow-sm: none; --shadow: 0 0 0 1px rgba(255,255,255,.02); --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #050a14; --surface: #0d1a2e; --surface-2: #13233b; --surface-3: #1a2d49;
  --border: #1d2d48; --border-strong: #2a3d5c;
  --text: #F1F3F8; --text-2: #c5cbd8; --muted: #8b93a7;
  --brand: #F5A623; --brand-hover: #FFB627; --brand-soft: #2a2312; --brand-ink: #0a1628; --brand-text: #F5A623;
  --accent: #FF7A2E; --accent-soft: #3a2010; --accent-ink: #FF9A5C;
  --ok: #5cc98b; --ok-soft: #15301f; --warn: #eaa64a; --warn-soft: #362812;
  --bad: #f07b6e; --bad-soft: #3a1c19; --info: #7fb0ea; --info-soft: #172a40;
  --violet: #b29cf0; --violet-soft: #271f3d;
  --shadow-sm: none; --shadow: 0 0 0 1px rgba(255,255,255,.02); --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.02rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.xs { font-size: .76rem; }
.hidden { display: none !important; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); }
.stack > * + * { margin-top: 1rem; }
.num-font { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; word-break: break-all; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* Tarjetas */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .85rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.card-head h2 .count { color: var(--muted); font-weight: 500; font-size: .9rem; }
.card.hoverable { transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s; cursor: pointer; }
.card.hoverable:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow), 0 10px 24px -10px rgba(16,24,20,.18); }
.empty { color: var(--muted); padding: 1.4rem .5rem; text-align: center; font-size: .92rem; }
.empty .icon { width: 28px; height: 28px; display: block; margin: 0 auto .4rem; opacity: .5; }

/* Estadísticas */
.stat { display: flex; gap: .9rem; align-items: center; }
.stat .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat .num { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: .82rem; }
.tone-brand { background: var(--brand-soft); color: var(--brand-text); }
.tone-accent { background: var(--accent-soft); color: var(--accent-ink); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-ok { background: var(--ok-soft); color: var(--ok); }
.tone-bad { background: var(--bad-soft); color: var(--bad); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }

/* Botones */
button, .btn {
  font: inherit; font-weight: 600; font-size: .88rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .5rem .9rem; min-height: 38px; cursor: pointer;
  background: var(--brand); color: var(--brand-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .08s;
}
button:hover, .btn:hover { background: var(--brand-hover); text-decoration: none; }
button:active, .btn:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: default; transform: none; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-soft { background: var(--brand-soft); color: var(--brand-text); }
.btn-soft:hover { background: var(--brand-soft); filter: brightness(.97); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: var(--bad); filter: brightness(1.08); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent); filter: brightness(1.05); }
.btn-sm { padding: .3rem .65rem; min-height: 31px; font-size: .82rem; font-weight: 550; }
.btn-icon { padding: 0; width: 36px; min-height: 36px; background: transparent; color: var(--muted); border-color: transparent; }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon.sm { width: 30px; min-height: 30px; }
.btn-link { background: none; border: 0; color: var(--brand-text); padding: 0; min-height: 0; font-weight: 550; }
.btn-link:hover { background: none; text-decoration: underline; }

/* Formularios */
label { display: block; font-size: .8rem; font-weight: 550; color: var(--text-2); margin-bottom: .3rem; }
input, select, textarea {
  font: inherit; width: 100%;
  padding: .55rem .7rem; min-height: 40px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
button:focus-visible, a:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=checkbox] { width: 17px; height: 17px; min-height: 0; accent-color: var(--brand); cursor: pointer; flex: none; }
.check { display: flex; align-items: center; gap: .55rem; color: var(--text); font-size: .92rem; font-weight: 450; margin: 0; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: .9rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: .4rem; border-top: 1px solid var(--border); padding-top: .9rem; }
.field-help { font-size: .78rem; color: var(--muted); margin-top: .3rem; min-height: 1em; }
.field-help.ok { color: var(--ok); font-weight: 550; }
.error-msg { color: var(--bad); font-size: .88rem; min-height: 1.2em; margin-top: .5rem; }
.search-input { position: relative; }
.search-input .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-input input { padding-left: 2.2rem; }

/* Chips de filtro */
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: .3rem .8rem; min-height: 32px; font-size: .84rem; font-weight: 550;
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { opacity: .6; margin-left: .2rem; font-weight: 500; }

/* Tablas */
.table-wrap { overflow-x: auto; margin: 0 -1.2rem; padding: 0 1.2rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--text); }
th.sort .arrow { opacity: .4; }
th.sort.on .arrow { opacity: 1; color: var(--brand-text); }
th, td { padding: .65rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; transition: background .1s; }
tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Etiquetas */
.tag {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 650; background: var(--surface-3); color: var(--text-2);
  white-space: nowrap; line-height: 1.5;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); }
.tag.brand { background: var(--brand-soft); color: var(--brand-text); }
.tag.violet { background: var(--violet-soft); color: var(--violet); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* Avatares */
.avatar {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: .82rem; letter-spacing: .02em;
}
.avatar.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 1.15rem; }
.avatar.sm { width: 28px; height: 28px; border-radius: 8px; font-size: .72rem; }

/* Barra de fases */
.fases { display: flex; gap: 3px; margin: .55rem 0; }
.fases span { flex: 1; height: 6px; border-radius: 4px; background: var(--surface-3); }
.fases span.done { background: var(--brand); }
.fases span.now { background: var(--accent); }

/* Línea de tiempo */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 .95rem 1.5rem; }
.timeline li::before {
  content: ""; position: absolute; left: 3px; top: .42rem; width: 10px; height: 10px;
  border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--surface);
}
.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 1.1rem; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: .78rem; color: var(--muted); }
.timeline li.pending::before { background: var(--surface); border: 2px solid var(--border-strong); }
.timeline li.current::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* Panel lateral (formularios) y diálogos */
.modal-bg {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 14, 11, .42);
  display: flex; justify-content: flex-end; animation: fade .18s ease;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); width: min(520px, 100%); height: 100%; overflow-y: auto;
  padding: 1.4rem 1.5rem 1.5rem; border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: slide-in .25s var(--ease); display: flex; flex-direction: column;
}
.modal form { display: flex; flex-direction: column; flex: 1; }
.modal .modal-title { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.1rem; }
.modal .modal-title h2 { margin: 0; font-size: 1.15rem; }
.modal .actions {
  display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap;
  margin-top: auto; padding-top: 1.1rem; position: sticky; bottom: -1.5rem; background: var(--surface); padding-bottom: .2rem;
}
.modal-bg.dialog { justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.modal-bg.dialog .modal { height: auto; max-height: 76vh; border-radius: 16px; border: 1px solid var(--border); width: min(460px, 100%); animation: pop .2s var(--ease); }
.modal-bg.dialog .modal .actions { position: static; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
@keyframes pop { from { transform: scale(.96) translateY(6px); opacity: 0; } }
@media (max-width: 640px) {
  .modal-bg { align-items: flex-end; }
  .modal { height: auto; max-height: 92vh; border-radius: 18px 18px 0 0; border-left: 0; animation: sheet .25s var(--ease); padding: 1.2rem 16px 1.2rem; }
  .modal-bg.dialog { align-items: flex-end; padding: 0; }
  .modal-bg.dialog .modal { border-radius: 18px 18px 0 0; max-height: 92vh; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }

/* Avisos */
#toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 70;
  display: flex; align-items: center; gap: .55rem;
  background: var(--text); color: var(--bg); padding: .7rem 1rem; border-radius: 12px;
  font-size: .9rem; font-weight: 550; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .2s, transform .2s var(--ease);
  max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: none; }
#toast.err { background: var(--bad); color: #fff; }
@media (max-width: 640px) { #toast { left: 16px; right: 16px; bottom: 16px; } }

/* Pantalla de acceso */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(700px 420px at 85% 0%, rgba(245,166,35,.20), transparent 60%),
              radial-gradient(600px 400px at 0% 100%, rgba(232,88,0,.12), transparent 60%),
              linear-gradient(165deg, #0f2140 0%, #0a1628 55%, #050a14 100%);
}
.auth { width: 100%; max-width: 400px; padding: 2rem 1.8rem; border-radius: 20px; box-shadow: var(--shadow-lg); }
.auth .logo { display: flex; flex-direction: column; align-items: center; gap: .3rem; margin-bottom: 1.2rem; justify-content: center; }
.auth .logo img { width: 96px; height: auto; filter: drop-shadow(0 6px 18px rgba(232,88,0,.35)); }
.auth .logo b { font-size: 1.35rem; letter-spacing: .08em; font-weight: 800; color: var(--text); }
.auth form > * + * { margin-top: .9rem; }
.auth button[type=submit] { width: 100%; min-height: 44px; }

.password-box {
  font: 650 1.25rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em;
  background: var(--accent-soft); color: var(--accent-ink); padding: .75rem .9rem; border-radius: 10px; text-align: center; user-select: all;
}
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.2rem; font-size: .9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Carga */
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
