/* =====================================================================
   EJH PRIVÉ · Estilos
   Identidad: negro ciruela, blanco lavanda y amatista, con ámbar oud
   como segundo color (Eduardo = amatista, Jhona = ámbar en todos los gráficos).
   ===================================================================== */
:root {
  --ink: #1c1424;
  --ink-2: #2a2033;
  --paper: #faf8fc;
  --surface: #ffffff;
  --line: #e7e0ef;
  --line-2: #d8cde4;
  --text: #22182b;
  --muted: #6e6478;
  --amatista: #6b3fa0;
  --amatista-2: #57318a;
  --amatista-soft: #efe7f8;
  --ambar: #b07a2a;
  --ambar-soft: #f6ebda;
  --ok: #2f7d5b;
  --ok-soft: #e3f2ea;
  --warn: #8f6210;
  --warn-soft: #fbf1dc;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;

  --socio1: var(--amatista);
  --socio2: var(--ambar);
  --c1: var(--amatista);
  --c2: var(--ambar);
  --c3: #b4a6c4;
  --c4: var(--ink);
  --c5: #7fa38f;
  --c6: #d3a8a0;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-lg: 14px;
  --r-md: 9px;
  --r-sm: 6px;
  --side: 248px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
h1, h2 { margin: 0; font-weight: 600; }
h1 { font-family: var(--serif); font-size: 30px; line-height: 1.15; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
a { color: var(--amatista); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--amatista); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.pad { padding: 0 20px 12px; margin: 0; }

/* ---------- Marca ---------- */
.brand-mark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 34px;
  letter-spacing: 0.06em;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
  gap: 0.28em;
}
.brand-mark span { font-weight: 400; font-style: italic; letter-spacing: 0; color: var(--amatista); font-size: 0.72em; }
.brand-mark.small { font-size: 21px; }
.side .brand-mark { color: #fff; }
.side .brand-mark span { color: #c9b3e6; }

/* ---------- Login ---------- */
.is-login { background: var(--ink); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border-radius: 18px;
  padding: 36px 32px 30px;
  box-shadow: 0 30px 80px rgba(10, 4, 18, 0.45);
}
.login-sub { color: var(--muted); margin: 4px 0 26px; }
.login form { display: grid; gap: 8px; }
.login label { font-weight: 600; font-size: 14px; margin-top: 8px; }
.who-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.who-btn {
  border: 1px solid var(--line-2); background: var(--paper); border-radius: 999px;
  padding: 6px 16px; cursor: pointer;
}
.who-btn.on, .who-btn:hover { border-color: var(--amatista); background: var(--amatista-soft); color: var(--amatista-2); }

/* ---------- Estructura ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: var(--side); flex: none; background: var(--ink); color: #d9cfe4;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 22px 14px 14px;
}
.side-brand { padding: 0 10px 18px; }
.nav { flex: 1; overflow-y: auto; }
.nav-group { margin-bottom: 14px; }
.nav-title { display: block; font-size: 12px; color: #8d7f9c; padding: 0 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--r-md);
  color: #e6ddef; text-decoration: none; font-size: 14.5px;
}
.nav a svg { width: 19px; height: 19px; flex: none; opacity: 0.8; }
.nav a:hover { background: var(--ink-2); }
.nav a.active { background: var(--amatista); color: #fff; }
.nav a.active svg { opacity: 1; }
.hist-det .chg { display: inline-block; margin-right: 10px; font-size: 13px; }
.rename-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 0 20px 16px; }
.rename-row .field { flex: 1 1 160px; }
.nav-count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }
.side-foot { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #a596b4; padding: 12px 10px 4px; border-top: 1px solid #33283d; }
.side-foot .user { margin-left: auto; color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #999; flex: none; }
.dot.ok { background: #5fcf98; }
.dot.warn { background: #e2b04a; }
.dot.bad { background: #ff6b5f; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.view { padding: 30px 34px 60px; max-width: 1320px; width: 100%; outline: none; }
.banner { padding: 10px 34px; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.scrim { display: none; }

/* ---------- Encabezado de vista ---------- */
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.intro { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }
.inline { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: var(--r-md); cursor: pointer; font-weight: 600; font-size: 14px;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--amatista); }
.btn.primary { background: var(--amatista); border-color: var(--amatista); color: #fff; }
.btn.primary:hover { background: var(--amatista-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 14px; padding: 12px; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; width: 32px; height: 32px; border-radius: var(--r-sm);
  display: inline-grid; place-items: center; color: var(--muted); font-size: 15px;
}
.icon-btn:hover { background: var(--amatista-soft); color: var(--amatista); }
.icon-btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.file-btn { position: relative; }

/* ---------- Paneles ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 18px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 10px; flex-wrap: wrap; }
.panel-head .muted { font-size: 13.5px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .panel, .grid-3 > .panel { margin-bottom: 18px; }

/* ---------- Indicadores ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin-bottom: 18px; }
.kpi { background: var(--surface); padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; }
.kpi-label { font-size: 13.5px; color: var(--muted); }
.kpi-value { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.kpi-hint { font-size: 12.5px; color: var(--muted); }
.kpi.tone-good .kpi-value { color: var(--ok); }
.kpi.tone-bad .kpi-value { color: var(--bad); }
.kpi.tone-warn .kpi-value { color: var(--warn); }
.kpi.tone-accent .kpi-value { color: var(--amatista); }

/* ---------- Barra de participación (elemento distintivo) ---------- */
.hero-share { padding-bottom: 20px; }
.share { padding: 4px 20px 0; }
.share-bar { display: flex; height: 46px; border-radius: 10px; overflow: hidden; gap: 3px; background: var(--paper); }
.share-seg { min-width: 4px; transition: flex 0.5s ease; }
.share-legend { display: flex; gap: 34px; margin-top: 14px; flex-wrap: wrap; }
.share-item { display: grid; grid-template-columns: auto auto; column-gap: 10px; align-items: baseline; }
.share-item i { width: 12px; height: 12px; border-radius: 3px; grid-row: span 2; align-self: center; }
.share-name { font-size: 14px; color: var(--muted); grid-column: 2; }
.share-pct { font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1.1; grid-column: 2; }
.share-amt { grid-column: 2; font-size: 14px; }

/* ---------- Gráficos ---------- */
.chart { width: 100%; height: auto; display: block; padding: 0 12px 4px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { font-size: 11px; fill: var(--muted); font-family: var(--sans); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 2px 20px 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart-empty { padding: 34px 20px 40px; color: var(--muted); text-align: center; font-size: 14px; }
.hbars { padding: 4px 20px 18px; display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--paper); border-radius: 999px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 999px; }
.hbar-val { font-weight: 600; min-width: 64px; text-align: right; }

/* ---------- Barra de herramientas y tablas ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.toolbar .search { flex: 1 1 220px; min-width: 160px; }
.toolbar select, .toolbar input, .filters select, .filters input, .period select, .period input, .inline select {
  border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 7px 10px; background: var(--surface); font-size: 14px; max-width: 100%;
}
.date-f { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.count { margin-left: auto; font-size: 13px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
.data th, .data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: var(--paper); white-space: nowrap; position: sticky; top: 0; }
.data tbody tr:hover { background: #fcfaff; }
.data .num { text-align: right; white-space: nowrap; }
.data tfoot td { font-weight: 700; background: var(--paper); }
.data td.actions { width: 1%; white-space: nowrap; text-align: right; }
.data.compact th, .data.compact td { padding: 8px 12px; }
.sort { border: 0; background: none; cursor: pointer; font: inherit; color: inherit; padding: 0; }
.sort:hover { color: var(--amatista); }
.matrix td:first-child { white-space: nowrap; }
.matrix tr.strong td { font-weight: 700; background: #fbf8fe; }
.matrix tr.section td { background: var(--ink); color: #fff; font-size: 12.5px; padding: 5px 12px; }
.more { margin: 12px auto 16px; display: flex; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); display: grid; gap: 14px; justify-items: center; }
.cierre input { width: 120px; text-align: right; border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 5px 8px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-neutral { background: var(--paper); color: var(--muted); }
.who { font-weight: 600; }
.who.s0 { color: var(--socio1); }
.who.s1 { color: var(--socio2); }
.who.shared { color: var(--ink); }

.alerts { list-style: none; margin: 0; padding: 0 20px 16px; display: grid; gap: 8px; font-size: 14px; }
.alerts li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice { font-size: 13.5px; background: var(--amatista-soft); color: var(--amatista-2); border-radius: var(--r-md); padding: 10px 14px; margin: 16px 0 0; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

.period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px 18px; align-items: flex-end; }
.filters label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

/* ---------- Formularios y modal ---------- */
dialog#modal {
  border: 0; padding: 0; border-radius: 16px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  box-shadow: 0 30px 90px rgba(28, 20, 36, 0.35); color: var(--text);
}
dialog#modal.wide { width: min(780px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(28, 20, 36, 0.55); }
dialog[open] { animation: pop 0.16s ease-out; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 8px; }
.modal-head h2 { font-family: var(--serif); font-size: 22px; }
.modal-body { padding: 8px 22px 6px; overflow-y: auto; }
.modal-foot { padding: 14px 22px 18px; border-top: 1px solid var(--line); }
.foot-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.foot-actions.start { justify-content: flex-start; padding: 0 20px 18px; }
.code-tag { margin-right: auto; font-size: 13px; color: var(--muted); background: var(--paper); padding: 4px 10px; border-radius: 999px; }
.confirm-text { margin: 4px 0 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.cfg .form-grid { padding: 0 20px 8px; }
.field { display: grid; gap: 5px; align-content: start; }
.field.full { grid-column: 1 / -1; }
.field label, .montos label { font-size: 13.5px; font-weight: 600; }
.req { color: var(--bad); }
.field input, .field select, .field textarea, .montos input, .login input, .cuenta-row input {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 9px 11px; background: var(--surface);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .login input:focus { border-color: var(--amatista); outline: 2px solid var(--amatista-soft); }
.help { color: var(--muted); font-size: 12.5px; }
.form-error { color: var(--bad); background: var(--bad-soft); border-radius: var(--r-md); padding: 9px 12px; margin: 12px 0 0; font-size: 14px; }
.cfg .form-error { margin: 0 20px 12px; }
.cfg .foot-actions { padding: 4px 20px 20px; }
.form-preview { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; padding: 10px 14px; background: var(--amatista-soft); border-radius: var(--r-md); font-size: 13.5px; }
.form-preview:empty { display: none; }
.modal-body .form-preview { position: sticky; bottom: 0; box-shadow: 0 -8px 16px var(--surface); }
.montos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.montos-single, .montos-shared { display: grid; gap: 5px; }
.montos-total { margin: 4px 0 0; font-size: 14px; }
.cuentas-edit { padding: 0 20px 12px; display: grid; gap: 8px; max-width: 560px; }
.cuenta-row { display: grid; grid-template-columns: 1fr 150px 32px; gap: 8px; align-items: center; }

/* ---------- Notificaciones ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--r-md); font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); border-left: 4px solid #5fcf98; transition: opacity 0.3s, transform 0.3s; max-width: 360px; }
.toast-bad { border-left-color: #ff6b5f; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .side { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform 0.2s ease; }
  .side.open { transform: none; }
  .scrim.on { display: block; position: fixed; inset: 0; background: rgba(28, 20, 36, 0.5); z-index: 30; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
  .topbar .brand-mark { color: #fff; }
  .topbar .brand-mark span { color: #c9b3e6; }
  .topbar .menu { color: #fff; font-size: 20px; }
  .topbar .dot { margin-left: auto; }
  .view { padding: 22px 16px 60px; }
  .banner { padding: 10px 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  h1 { font-size: 25px; }
  .form-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 21px; }
  .share-pct { font-size: 28px; }
  .view-head .btn.primary { width: 100%; }
  .toolbar .search { flex-basis: 100%; }
  .count { margin-left: 0; }
  /* Tablas como tarjetas */
  table.data:not(.matrix) thead { display: none; }
  table.data:not(.matrix), table.data:not(.matrix) tbody, table.data:not(.matrix) tr, table.data:not(.matrix) td { display: block; width: 100%; }
  table.data:not(.matrix) tr { border-bottom: 1px solid var(--line); padding: 8px 4px; }
  table.data:not(.matrix) td { border: 0; padding: 4px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.data:not(.matrix) td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; }
  table.data:not(.matrix) td.actions { justify-content: flex-end; width: 100%; }
  table.data:not(.matrix) td.actions::before { content: none; }
  table.data:not(.matrix) tfoot td::before { content: none; }
  .cuenta-row { grid-template-columns: 1fr 110px 32px; }
  #toasts { left: 12px; right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Decants: tarjetas de frascos abiertos */
.dec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; padding: 4px 20px 20px; }
.dec-card { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; display: grid; gap: 10px; background: var(--surface); }
.dec-card.is-empty { opacity: .7; }
.dec-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.dec-ubic { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f1ebf8; color: var(--amatista); white-space: nowrap; }
.dec-ml strong { font-family: var(--serif); font-size: 24px; }
.meter { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--amatista); border-radius: inherit; }
.dec-alcanza { font-size: 14px; line-height: 1.5; }
.dec-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.dec-card details summary { cursor: pointer; font-size: 13.5px; color: var(--muted); }
.dec-card details .table-wrap { margin-top: 8px; }
/* El detalle de ml ocupa todo el ancho al abrirse y nunca se sale de la tarjeta */
.dec-card { min-width: 0; }
.dec-card:has(details[open]) { grid-column: 1 / -1; }
.dec-card details .table-wrap { overflow-x: auto; max-width: 100%; }
.dec-card details table { min-width: 520px; }
.dec-card details td, .dec-card details th { white-space: nowrap; }
.dec-card details td:nth-child(3), .dec-card details td:nth-child(4) { white-space: normal; }

/* Pestañas de Productos (Perfumes / Decants) */
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 18px; }
.subtabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 16px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.subtabs button[aria-selected="true"] { color: var(--amatista); border-bottom-color: var(--amatista); }
.subtabs button .muted { font-weight: 400; margin-left: 4px; }

/* ---------- Inversionistas mayoristas ---------- */
.may-pick { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 18px; }
.may-pick .who-btn { width: auto; }
.may-body .view-head { margin-bottom: 14px; }
.may-body .view-head h1 { font-size: 20px; }
.may-ficha { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 4px 20px 18px; font-size: 14px; color: var(--muted); }
.may-ficha b { color: var(--text); }
.may-body .panel > .notice { margin: 0 20px 18px; }

/* Tienda web */
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice .btn { margin-left: 8px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.steps { margin: 0; padding: 4px 20px 18px 40px; line-height: 1.7; }
.web-form { margin: 14px 0 16px; }
