/* Edeon — interfaz operativa. CSS propio, sin framework. */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --border: #e2e0da;
  --text: #1d1f1c;
  --muted: #6b6e67;
  --accent: #2f6b4f;
  --accent-soft: #e3efe8;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --info: #2d5b8a;
  --info-soft: #e3edf7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 15, 0.05);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Modo oscuro: lo elige cada persona con el botón de la barra (base.html). */
:root[data-theme="dark"] {
  --bg: #141614;
  --surface: #1c1f1c;
  --surface-2: #232723;
  --border: #2f342f;
  --text: #e8eae5;
  --muted: #9aa097;
  --accent: #7cc4a0;
  --accent-soft: #1f3329;
  --warn: #e2b55a;
  --warn-soft: #3a2f17;
  --info: #8db8e6;
  --info-soft: #1d2a38;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; font-weight: 620; }
h3 { font-size: 0.95rem; font-weight: 620; }
p { margin: 0; }

code, .key { font-family: var(--mono); font-size: 0.82em; color: var(--muted); }

/* ── Estructura ─────────────────────────────────────────────────────────── */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; font-weight: 700; font-size: 1.05rem; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: var(--surface);
  display: grid; place-items: center; font-size: 0.85rem;
}

.nav-section { margin: 14px 8px 6px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; border-radius: 7px; color: var(--text);
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 32px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar-tenant { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-tenant strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.9rem; }

.content { padding: 28px 32px 64px; max-width: 1180px; width: 100%; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 6px; max-width: 70ch; }
.breadcrumb { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }

.section { margin-top: 30px; }
.section > h2 { margin-bottom: 12px; display: flex; align-items: baseline; gap: 8px; }
.section > h2 .count { color: var(--muted); font-weight: 500; font-size: 0.9rem; }

/* ── Componentes ────────────────────────────────────────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
}
a.card { display: block; color: inherit; transition: border-color 0.12s ease; }
a.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin-bottom: 4px; }
.card p { color: var(--muted); font-size: 0.9rem; }
.card-foot { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid-stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* El número se achica con la caja y nunca se corta: "$ 1.117.501.820" entra entero. */
.stat { container-type: inline-size; min-width: 0; }
.stat .value { font-size: clamp(1rem, 11cqi, 1.7rem); font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat .label { color: var(--muted); font-size: 0.88rem; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 550;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th {
  text-align: left; font-weight: 600; font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2);
  padding: 9px 14px; border-bottom: 1px solid var(--border);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td .sub { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: 0.92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.search {
  width: 280px; max-width: 100%; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
.search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.button {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
}
.button:hover { border-color: var(--accent); text-decoration: none; }
.button-primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.button-primary:hover { filter: brightness(1.08); }
.button-link { border: none; background: none; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
.button-link:hover { color: var(--text); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.muted { color: var(--muted); }
.note { background: var(--surface-2); border-radius: 8px; padding: 10px 14px; color: var(--muted); font-size: 0.9rem; }

details.catalog { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
details.catalog + details.catalog { margin-top: 8px; }
details.catalog summary {
  cursor: pointer; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  list-style: none;
}
details.catalog summary > span:first-child { flex: 1; min-width: 0; }
details.catalog summary::-webkit-details-marker { display: none; }
details.catalog summary::after { content: "›"; color: var(--muted); transition: transform 0.15s ease; }
details.catalog[open] summary::after { transform: rotate(90deg); }
details.catalog .items { border-top: 1px solid var(--border); }
details.catalog table { font-size: 0.88rem; }

.htmx-request.search { opacity: 0.7; }

/* ── Acceso ─────────────────────────────────────────────────────────────── */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth h1 { font-size: 1.3rem; margin: 16px 0 4px; }
.field { display: grid; gap: 6px; margin-top: 14px; }
.field label { font-size: 0.88rem; font-weight: 550; }
.field input {
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
.error { color: #b3261e; font-size: 0.88rem; margin-top: 12px; }

.tenant-list { display: grid; gap: 8px; margin-top: 18px; }
.tenant-list button { width: 100%; justify-content: space-between; }

/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar {
    position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border);
    padding: 12px 16px; display: flex; align-items: center; gap: 12px; overflow-x: auto;
  }
  .brand { padding: 0; }
  .nav-section { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav a { white-space: nowrap; padding: 6px 10px; }
  .nav a .badge { display: none; }
  .topbar { padding: 10px 16px; }
  .content { padding: 20px 16px 48px; }
  .two-col { grid-template-columns: 1fr; }
  .search { width: 100%; }
}

/* ── Operación ──────────────────────────────────────────────────────────── */

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.date-filter { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.date-filter input {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
tr.voided td { opacity: 0.55; }
tr.voided td strong { text-decoration: line-through; }

/* ── Interfaz operativa ─────────────────────────────────────────────────── */

.flash { background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 10px 14px; margin-bottom: 18px; font-weight: 550; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; flex-wrap: wrap; }
.big { font-size: 1.4rem; font-weight: 650; white-space: nowrap; }
table.plain { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.plain td { padding: 6px 0; border-bottom: 1px solid var(--border); }
table.plain tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
tr.group-row td { background: var(--surface-2); font-weight: 600; font-size: 0.85rem; padding: 7px 14px; }
.button-small { padding: 5px 10px; font-size: 0.85rem; }
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-items {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 230px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); padding: 6px; display: grid;
}
.menu-right .menu-items { left: auto; right: 0; }
.menu-items a { padding: 8px 10px; border-radius: 6px; color: var(--text); text-align: left; }
.menu-items a:hover { background: var(--surface-2); text-decoration: none; }
.action-form .field select, .action-form .field input:not([type=checkbox]) {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
.action-form .field small { font-size: 0.82rem; }
.req { color: #b3261e; }
.money { display: grid; grid-template-columns: 80px 1fr; gap: 8px; }
.form-errors { background: #fdecea; color: #8c1d18; border-radius: 8px; padding: 10px 14px; margin-bottom: 6px; }
.form-errors p + p { margin-top: 4px; }
.preview { margin-top: 18px; background: var(--accent-soft); border-radius: 8px; padding: 12px 16px; }
.preview h3 { margin-bottom: 6px; }
.preview ul { margin: 0; padding-left: 18px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; }
.form-actions button[disabled] { opacity: 0.5; cursor: not-allowed; }
:root[data-theme="dark"] .form-errors { background: #3a1a17; color: #f2b8b5; }

/* ── Indicadores ────────────────────────────────────────────────────────── */

.params select, .params input { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.flag.ok { color: var(--accent); font-weight: 700; }
.flag.no { color: var(--muted); }
tr.alert-row td { background: var(--warn-soft); }

/* ── Consulta ───────────────────────────────────────────────────────────── */

.preguntar { margin-bottom: 8px; }
.preguntar-fila { display: flex; gap: 8px; margin-top: 8px; }
.preguntar-fila input { flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.htmx-indicator { display: none; margin-top: 10px; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }
.respuesta { margin-top: 14px; padding: 12px 16px; border-radius: 8px; background: var(--surface-2); }
.respuesta p + p, .respuesta ul { margin-top: 8px; }
.respuesta ul { padding-left: 18px; }
.flash-error { background: var(--warn-soft); color: var(--warn); }
.filters select { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }

/* Cómo funciona tu empresa: el modelo en capas, con el sistema visual de Edeon */
.mapa {
  --m-base: #EDEFF2; --m-surface: #FFFFFF; --m-raised: #E3E6EA; --m-hair: #CDD2D8;
  --m-steel: #4F6071; --m-muted: #5E656D; --m-text: #0A0B0D; --m-signal: #9A6A1C;
  position: relative; background: var(--m-base); border: 1px solid var(--m-hair);
  border-radius: 4px; padding: 8px 12px; margin-bottom: 8px;
}
:root[data-theme="dark"] .mapa {
  --m-base: #0A0B0D; --m-surface: #141619; --m-raised: #1C1F24; --m-hair: #2A2E34;
  --m-steel: #8FA3B5; --m-muted: #B8BDC4; --m-text: #EDEFF2; --m-signal: #D8A24A;
}
.mapa-svg { display: block; width: 100%; height: auto; font-family: "Inter Tight", "Inter", var(--font); }
.mapa-svg .m-plano { fill: var(--m-surface); stroke: var(--m-hair); stroke-width: 1; }
.mapa-svg .m-borde { fill: var(--m-raised); stroke: var(--m-hair); stroke-width: 1; }
.mapa-svg .m-raya { stroke: var(--m-hair); stroke-width: 1; }
.mapa-svg .m-hilo { fill: none; stroke: var(--m-steel); stroke-width: 1; stroke-dasharray: 1.5 4; opacity: 0.55; }
.mapa-svg .m-titulo { fill: var(--m-text); font-size: 17px; font-weight: 600; letter-spacing: 0.02em; }
.mapa-svg .m-item, .mapa-svg .m-chip text, .mapa-svg .m-nombre, .mapa-svg .m-cantidad {
  font-family: "JetBrains Mono", var(--mono);
}
.mapa-svg .m-item { fill: var(--m-muted); font-size: 12.5px; }
.mapa-svg .m-link { fill: var(--m-steel); text-decoration: underline; text-underline-offset: 3px; }
.mapa-svg a:hover .m-link, .mapa-svg a:focus .m-link { fill: var(--m-signal); }
.mapa-svg .m-vinculo { fill: none; stroke: var(--m-steel); stroke-width: 1.2; stroke-dasharray: 2 4; }
.mapa-svg .m-chip rect { fill: var(--m-raised); stroke: var(--m-hair); stroke-width: 1; }
.mapa-svg .m-chip text { fill: var(--m-muted); font-size: 10.5px; letter-spacing: 0.06em; }
.mapa-svg .m-nodo { cursor: pointer; }
.mapa-svg .m-nodo .m-base { fill: none; stroke: var(--m-hair); stroke-width: 1; }
.mapa-svg .m-nodo .m-fondo { fill: var(--m-surface); }
.mapa-svg .m-nodo .m-icono path { fill: none; stroke: var(--m-steel); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.mapa-svg .m-nombre { fill: var(--m-text); font-size: 11.5px; font-weight: 500; letter-spacing: 0.08em; }
.mapa-svg .m-cantidad { fill: var(--m-muted); font-size: 11px; }
.mapa-svg .m-nodo:hover .m-icono path, .mapa-svg .m-nodo:focus .m-icono path,
.mapa-svg .m-nodo.activo .m-icono path { stroke: var(--m-signal); }
.mapa-svg .m-nodo.activo .m-base, .mapa-svg .m-nodo:focus .m-base { stroke: var(--m-signal); stroke-width: 1.5; }
.mapa-svg .m-nodo.activo .m-cantidad { fill: var(--m-signal); font-weight: 500; }
.mapa-svg .m-nodo:focus { outline: none; }
.mapa-tarjeta {
  position: absolute; left: 16px; top: 33%; width: 250px; z-index: 2; background: var(--m-surface);
  border: 1px solid var(--m-hair); border-radius: 4px; padding: 14px 16px; color: var(--m-text);
  font-family: "Inter Tight", "Inter", var(--font);
}
.mapa-tarjeta-tipo { font-family: "JetBrains Mono", var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.mapa-tarjeta-dato { font-family: "JetBrains Mono", var(--mono); font-size: 32px; font-weight: 500; color: var(--m-signal); margin-top: 8px; }
.mapa-tarjeta-dato small { font-size: 12px; color: var(--m-muted); }
.mapa-tarjeta p { color: var(--m-muted); font-size: 0.9rem; margin: 8px 0; }
.mapa-tarjeta a { color: var(--m-steel); font-size: 0.9rem; }
.mapa-cerrar { position: absolute; right: 8px; top: 6px; border: none; background: none; color: var(--m-muted); font-size: 20px; cursor: pointer; min-width: 32px; min-height: 32px; }
.ficha { scroll-margin-top: 16px; }
.ficha:target { outline: 2px solid var(--accent); }
.ficha h3 { font-size: 1rem; }
.fichas { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.ficha-datos { margin: 12px 0 0; font-size: 0.92rem; }
.ficha-datos dt { margin-top: 10px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.ficha-datos dd { margin: 3px 0 0; }

/* Conectores */
.conector-tarjeta { color: inherit; text-decoration: none; display: block; }
.conector-tarjeta:hover { border-color: var(--accent); }
.conector-pronto { opacity: 0.7; }

.tema { font-size: 0.9rem; }
