/* Contacta — sistema de diseño "Botanical Ledger".
   Libro mayor / guía de campo: serif Spectral en títulos, IBM Plex Sans en la UI,
   IBM Plex Mono tabular en toda cifra. Paleta natural pero ejecutiva: verdes de
   bosque + tierras, nada de azul SaaS. Fuente de verdad visual. */

:root {
  /* Paleta "botanical ledger" — natural pero ejecutiva. */
  --ground: #F6F8F5;        /* paper: papel verdoso, no blanco puro */
  --surface: #ffffff;
  --surface-2: #EEF2EC;
  --surface-3: #E1E8E0;
  --border: #DCE4DC;        /* line */
  --border-soft: #E8EEE7;

  --text: #14241B;          /* ink: casi-negro verdoso */
  --text-dim: #4E5B52;
  --text-faint: #6B7A6F;    /* sage */

  --ink: #1E5C45;           /* forest: acento y acciones */
  --ink-hover: #174A37;
  --ink-on: #F6F8F5;

  --good: #2F7D55; --good-bg: #E3EEE6;
  --warn: #B5713B; --warn-bg: #F5EBDF;   /* clay */
  --crit: #B3402E; --crit-bg: #F6E7E2;
  --info: #4C7C84; --info-bg: #E6EFF0;   /* mineral */
  --gold: #B5713B;                        /* clay: secundario cálido */

  --radius: 12px;
  --radius-sm: 8px;
  /* sombras de "instrumento": muy sutiles */
  --shadow: 0 1px 2px rgba(20, 36, 27, .04), 0 4px 14px rgba(20, 36, 27, .05);
  --shadow-lg: 0 2px 6px rgba(20, 36, 27, .07), 0 16px 40px rgba(20, 36, 27, .11);

  /* trío "field guide": serif para títulos, sans para la UI, mono para cifras */
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --font: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

/* Títulos = "field guide" serif */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; margin: 0; }
h1.page-title { font-size: 30px; line-height: 1.15; }

/* .tnum = "instrumento de lectura": toda cifra en mono tabular, como libro mayor */
.tnum { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .95em; }
.mono { font-family: var(--mono); font-size: 13px; }
a { color: var(--text); }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em;
  font-weight: 600; color: var(--text-faint);
}

/* --- Shell ------------------------------------------------------------- */

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

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 22px 14px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 10px 20px; }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand .brand-name { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; font-size: 17px; line-height: 1.15; }
.brand .brand-eyebrow { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .14em; font-weight: 500; color: var(--text-faint); }

.nav-label {
  font-family: var(--mono);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; font-weight: 600;
  color: var(--text-faint); padding: 16px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 12px; margin: 1px 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--text-dim); text-decoration: none;
  border-radius: var(--radius-sm); transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--ink); color: var(--ink-on); }
.nav-item .dot { width: 6px; height: 6px; border-radius: 100px; background: currentColor; opacity: .55; flex: none; }
.nav-item svg.nav-ico { width: 17px; height: 17px; flex: none; opacity: .85; }

/* Grupos colapsables del menú (estilo Shopify/Klaviyo): header con chevron */
.nav-group { margin-top: 10px; }
.nav-group-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 12px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--text-dim);
  border-radius: var(--radius-sm); transition: background .12s, color .12s;
}
.nav-group-toggle:hover { background: var(--surface-2); color: var(--text); }
.nav-group-toggle svg.nav-ico { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-group-toggle .grow { flex: 1; text-align: left; }
.nav-group-toggle .chev { transition: transform .15s; opacity: .6; flex: none; }
.nav-group.open .nav-group-toggle .chev { transform: rotate(90deg); }
.nav-group-body { display: none; }
.nav-group.open .nav-group-body { display: block; }
.nav-group-body .nav-item { padding-left: 39px; font-size: 13.5px; }

/* Menú contextual (⋮ de las filas) */
.menu-pop {
  position: absolute; z-index: 80; min-width: 180px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 5px;
}
.menu-pop button {
  display: block; width: 100%; text-align: left; padding: 8px 12px;
  border: 0; background: none; cursor: pointer; font: inherit; font-size: 13.5px;
  border-radius: 7px; color: var(--text);
}
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop button.danger { color: var(--crit); }
.icon-badge { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.icon-badge svg { width: 15px; height: 15px; flex: none; }

.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border-soft); padding-top: 12px; }
.userbox { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); }
.userbox img { width: 30px; height: 30px; border-radius: 100px; background: var(--surface-3); }
.userbox .u-email { font-size: 12.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox .u-name { font-size: 13.5px; font-weight: 600; line-height: 1.2; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 30px;
  background: color-mix(in srgb, var(--ground) 82%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
}
.crumb { font-size: 13.5px; color: var(--text-dim); }
.crumb b { color: var(--text); font-weight: 620; }

.content { max-width: 1140px; margin: 0 auto; padding: 30px 28px 60px; animation: fade-up .25s ease; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head .sub { color: var(--text-dim); font-size: 14px; margin-top: 4px; }

/* --- Botones, inputs ----------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--ink-on); }
.btn.primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 42%, var(--border)); background: var(--surface); }
.btn.danger:hover { background: var(--crit-bg); border-color: var(--crit); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.full { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; pointer-events: none; }

label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-family: var(--mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; font-weight: 600; color: var(--text-dim); margin-bottom: 6px;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="url"], input[type="datetime-local"], select, textarea {
  width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14.5px; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(30, 92, 69, .12);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

/* --- Cards, tiles, tablas ------------------------------------------------ */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card + .card { margin-top: 18px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; border-bottom: 1px solid var(--border-soft);
}
.card-head h2 { font-size: 17px; }
.card-head .hint { font-size: 13px; color: var(--text-faint); }
.card-pad { padding: 20px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
}
.tile .t-label { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; font-weight: 600; color: var(--text-faint); }
.tile .t-value { font-family: var(--mono); font-size: 25px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 5px; }
.tile .t-delta { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .1em; font-weight: 600; color: var(--text-faint); background: var(--surface-2);
  padding: 9px 14px; border-bottom: 1px solid var(--border);
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: default; transition: background .12s; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.tbl-wrap { overflow-x: auto; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2.5px 10px 2.5px 8px; border-radius: 100px;
  font-size: 12px; font-weight: 600;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 100px; background: currentColor; }
.pill.good { color: var(--good); background: var(--good-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.crit { color: var(--crit); background: var(--crit-bg); }
.pill.info { color: var(--info); background: var(--info-bg); }
.pill.dim { color: var(--text-dim); background: var(--surface-2); }

.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--border-soft);
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .r-title { font-weight: 600; font-size: 14.5px; }
.row .r-sub { font-size: 13px; color: var(--text-dim); }

/* --- Login ---------------------------------------------------------------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 400px; max-width: 100%; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 38px 36px 34px; text-align: center;
  animation: fade-up .25s ease;
}
.login-card h1 { font-size: 28px; margin: 18px 0 6px; }
.login-card .sub { color: var(--text-dim); font-size: 14px; margin-bottom: 26px; }
.google-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  padding: 11px 16px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--ink-on); border: 1px solid var(--ink);
  font: inherit; font-size: 14.5px; font-weight: 620; cursor: pointer; text-decoration: none;
  transition: background .12s;
}
.google-btn:hover { background: var(--ink-hover); }
.google-btn:active { transform: translateY(1px); }

/* --- Modales, toasts, spinner, empty -------------------------------------- */

.overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: rgba(20, 36, 27, .3); backdrop-filter: blur(3px);
  animation: fade .15s ease;
}
.modal {
  width: 480px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 24px;
}
.modal h3 { font-size: 19px; margin-bottom: 16px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--good);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 11px 16px; font-size: 14px; min-width: 240px; max-width: 380px;
  animation: slidein .15s ease;
}
.toast.err { border-left-color: var(--crit); }
.toast.warn { border-left-color: var(--warn); }

.spinner {
  width: 22px; height: 22px; border-radius: 100px;
  border: 3px solid var(--surface-3); border-top-color: var(--ink);
  animation: spin .7s linear infinite; margin: 40px auto;
}
.empty { text-align: center; padding: 54px 20px; color: var(--text-dim); }
.empty .e-icon { font-size: 34px; opacity: .35; margin-bottom: 10px; }
.empty h3 { font-size: 17px; color: var(--text); margin-bottom: 4px; }
.empty p { margin: 0 0 16px; font-size: 14px; }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 7px 16px; font-size: 14px; }
.kv dt { color: var(--text-faint); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; padding-top: 2px; }
.kv dd { margin: 0; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input[type="text"] { max-width: 300px; }
.filters select { width: auto; }

.editor-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
@media (max-width: 1100px) {
  .editor-grid { grid-template-columns: 1fr 1fr; }
  .editor-grid > .editor-preview { grid-column: 1 / -1; order: 3; }
}
@media (max-width: 700px) { .editor-grid { grid-template-columns: 1fr; } }

@keyframes fade { from { opacity: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }
@keyframes slidein { from { opacity: 0; transform: translateX(14px); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Responsive ------------------------------------------------------------ */

.hamburger { display: none; }
.scrim { display: none; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; width: 252px;
    transform: translateX(-100%); transition: transform .15s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim.show { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(20, 36, 27, .3); }
  .hamburger { display: inline-flex; }
  .content { padding: 20px 16px 60px; }
  .topbar { padding: 12px 16px; }
}

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

/* --- Composer simple (M6.2) -------------------------------------------------- */

.composer-banner {
  background: var(--warn-bg); color: var(--warn);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 12px;
}
.composer-toolbar {
  display: flex; gap: 4px; flex-wrap: wrap;
  border: 1.5px solid var(--border); border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding: 6px 8px; background: var(--surface-2);
}
.composer-toolbar button {
  border: 0; background: none; cursor: pointer; font-size: 13px;
  padding: 5px 9px; border-radius: 6px; color: var(--text);
  font-family: inherit;
}
.composer-toolbar button:hover { background: var(--surface-3); }
.composer-toolbar button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.composer-body {
  min-height: 260px; border: 1.5px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 14px 16px; font-size: 15px; line-height: 1.6; background: var(--surface);
  overflow-y: auto; max-height: 55vh;
}
.composer-body:focus { outline: none; box-shadow: 0 0 0 3px rgba(30, 92, 69, .12); }
.composer-body p { margin: 0 0 10px; }
.composer-body a { color: var(--info); }
.nm-chip {
  display: inline-block; background: var(--ink); color: var(--ink-on);
  border-radius: 100px; padding: 6px 16px; font-size: 13.5px; font-weight: 620;
  margin: 4px 0; cursor: pointer; user-select: none;
}
.nm-chip:hover { background: var(--ink-hover); }
