/* ============================================================
   P2P Manager — SaaS design system
   Theme variables (--bg-main, --surface, --primary, ...) are set
   at runtime by setTheme() in app.js; everything below builds on them.
   ============================================================ */

:root {
  /* Defaults (dark) — overridden live by the theme switcher */
  --bg-main: #070d1a;
  --bg-soft: #0b1322;
  --surface: rgba(17, 26, 43, 0.9);
  --line: rgba(96, 124, 173, 0.18);
  --text: #e8edf7;
  --text-soft: #95a3c0;
  --primary: #f4c20f;
  --primary-2: #f7d84c;
  --bg-gradient-1: rgba(10, 36, 80, 0.10);
  --bg-gradient-2: rgba(26, 67, 130, 0.22);
  --bg-gradient-3: rgba(13, 92, 76, 0.14);

  /* Derived / fixed tokens */
  --surface-2: color-mix(in srgb, var(--surface) 70%, #000 8%);
  --surface-hover: color-mix(in srgb, var(--surface) 82%, var(--text) 6%);
  --line-strong: color-mix(in srgb, var(--line) 100%, var(--text) 14%);
  --primary-soft: color-mix(in srgb, var(--primary) 16%, transparent);
  --primary-ink: #0b1220;

  --good: #2ecc77;
  --good-soft: color-mix(in srgb, var(--good) 16%, transparent);
  --warn: #eab308;
  --warn-soft: color-mix(in srgb, var(--warn) 16%, transparent);
  --danger: #f04444;
  --danger-soft: color-mix(in srgb, var(--danger) 16%, transparent);

  --r-xl: 18px;
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 8px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 30px rgba(2, 8, 20, 0.35);
  --shadow-lg: 0 24px 60px rgba(2, 8, 20, 0.5);

  --sidebar-w: 252px;
  --gap: 16px;

  --font-body: "Manrope", system-ui, sans-serif;
  --font-head: "Space Grotesk", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 12% -10%, var(--bg-gradient-2), transparent 55%),
    radial-gradient(1000px 700px at 100% 110%, var(--bg-gradient-3), transparent 50%),
    var(--bg-main);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-family: var(--font-head); font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--primary); text-decoration: none; }
::selection { background: var(--primary-soft); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
*::-webkit-scrollbar-track { background: transparent; }

.is-hidden { display: none !important; }

/* ============================================================
   Login
   ============================================================ */
.login-screen { position: fixed; inset: 0; z-index: 40; overflow-y: auto; padding: 24px;
  display: grid; place-items: center;
  background: radial-gradient(800px 500px at 50% -10%, var(--bg-gradient-2), transparent 60%), var(--bg-main); }
.landing-screen { position: fixed; inset: 0; z-index: 40; overflow-y: auto; padding: 0 20px 24px;
  background: radial-gradient(900px 560px at 50% -10%, var(--bg-gradient-2), transparent 60%), var(--bg-main); }
.landing-nav { max-width: 1060px; margin: 0 auto; padding: 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.landing-nav-cta { display: flex; gap: 8px; }
.landing { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 40px; align-items: center;
  min-height: min(600px, 84vh); }
.landing-hero { padding: 8px 0; }
.landing-title { font-size: 30px; line-height: 1.15; margin: 12px 0 8px; }
.landing-sub { color: var(--text-soft); font-size: 15px; max-width: 54ch; margin: 0 0 18px; }
.landing-feats { list-style: none; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px 16px; }
.landing-feats li { font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.landing-feats i { color: var(--primary); }
.landing-pricing { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 12px; }
.lp-card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); padding: 14px 16px; }
.lp-card--accent { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.lp-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.lp-tag { font-size: 10px; font-weight: 600; background: var(--primary); color: var(--primary-ink); padding: 1px 7px; border-radius: 999px; }
.lp-price { font-size: 26px; font-weight: 800; margin: 4px 0; }
.lp-price span { font-size: 13px; font-weight: 500; color: var(--text-soft); }
.lp-desc { font-size: 12px; color: var(--text-soft); }
.landing-note { font-size: 12px; color: var(--text-soft); margin: 6px 0 0; }
@media (max-width: 860px) {
  .landing { grid-template-columns: 1fr; gap: 22px; }
  .landing-title { font-size: 24px; }
  .login-card { order: -1; }
}
@media (max-width: 460px) { .landing-feats { grid-template-columns: 1fr; } }
.grace-banner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  background: rgba(245, 158, 11, 0.14); border-bottom: 1px solid rgba(245, 158, 11, 0.45);
  color: var(--text); padding: 9px 16px; font-size: 13px; }
.lockout-feats { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; font-size: 13px; }
.lockout-feats li { display: flex; align-items: center; gap: 8px; }
/* Landing extendida */
.landing-page { max-width: 1060px; margin: 0 auto; padding: 8px 0 24px; }
.landing-hero--center { text-align: center; max-width: 780px; margin: 24px auto 8px; }
.landing-hero--center .landing-sub { margin-left: auto; margin-right: auto; }
.hero-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--primary-soft);
  color: var(--primary); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px;
  font-size: 12.5px; font-weight: 600; margin-bottom: 14px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 20px 0 10px; }
.landing-logos--center { justify-content: center; }
.landing-logos { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.ex-chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 13px; font-weight: 600; font-size: 13px; background: var(--surface); }
.ex-chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--primary)); }
.landing-block { margin: 44px 0 0; }
.landing-h2 { font-size: 22px; text-align: center; margin: 0 0 4px; }
.landing-h2-sub { text-align: center; color: var(--text-soft); font-size: 13.5px; margin: 0 0 20px; }
.landing-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 20px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.step-n { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-weight: 800; margin-bottom: 10px; }
.step h3 { font-size: 15px; margin: 0 0 6px; }
.step p { color: var(--text-soft); font-size: 13px; margin: 0; }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 20px; }
.feat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; }
.feat i { font-size: 22px; color: var(--primary); }
.feat h3 { font-size: 14.5px; margin: 8px 0 5px; }
.feat p { color: var(--text-soft); font-size: 12.5px; margin: 0; }
.pricing2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; max-width: 720px; margin: 0 auto; }
.lp2 { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 22px; }
.lp2--accent { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.lp2-badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--primary);
  color: var(--primary-ink); font-size: 11px; font-weight: 700; padding: 2px 12px; border-radius: 999px; }
.lp2-name { font-weight: 700; font-size: 16px; }
.lp2-price { font-size: 32px; font-weight: 800; margin: 4px 0 4px; }
.lp2-price span { font-size: 14px; font-weight: 500; color: var(--text-soft); }
.lp2-annual { font-size: 12.5px; font-weight: 600; color: var(--primary); margin: 0 0 12px; }
.lp2 ul { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; font-size: 13px; }
.lp2 ul i { color: var(--good); margin-right: 6px; }
.faq { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px; }
.faq-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; }
.faq-item h3 { font-size: 14px; margin: 0 0 6px; }
.faq-item p { color: var(--text-soft); font-size: 13px; margin: 0; }
.landing-footer { margin: 44px 0 10px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; font-size: 12px; }
@media (max-width: 860px) {
  .landing-steps, .features-grid, .faq, .pricing2 { grid-template-columns: 1fr; }
}
.login-card { width: min(400px, 100%); border-radius: var(--r-xl); border: 1px solid var(--line);
  background: var(--surface); padding: 28px; box-shadow: var(--shadow-lg); display: grid; gap: 14px; }
.login-card h1 { font-size: 24px; }
.login-card .brand { margin-bottom: 4px; }
.stack-sm { display: grid; gap: 12px; }

/* ============================================================
   App layout
   ============================================================ */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

/* Mobile overlay — always out of grid flow so it never consumes a column */
.scrim { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.5); display: none; }
.scrim.is-open { display: block; }

/* Sidebar */
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px;
  padding: 20px 16px; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-soft) 90%, #000 6%), var(--bg-soft)); }
.brand { margin: 0; font-family: var(--font-head); font-weight: 700; font-size: 22px; letter-spacing: 0.01em;
  display: flex; align-items: center; gap: 8px; padding: 4px 8px; }
.brand-mark { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: 8px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-ink);
  font-size: 13px; font-weight: 700; }

.nav-list { display: grid; gap: 3px; margin-top: 6px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.nav-section { padding: 14px 12px 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-soft); opacity: 0.7;
  display: flex; align-items: center; gap: 6px; }
/* Tag "solo admin" junto al encabezado de la sección Administración. */
.nav-tag { font-size: 8.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent);
  border-radius: 999px; padding: 1px 6px; opacity: 0.9; }
.nav-btn { position: relative; display: flex; align-items: center; gap: 11px; width: 100%;
  border: 0; border-radius: var(--r-md); padding: 10px 12px; background: transparent; color: var(--text-soft);
  font-family: var(--font-body); font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer;
  transition: background 120ms ease, color 120ms ease; }
.nav-btn i { font-size: 17px; width: 20px; text-align: center; }
.nav-btn:hover { background: var(--surface-hover); color: var(--text); }
.nav-btn.is-active { background: var(--primary-soft); color: var(--text); }
.nav-btn.is-active::before { content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--primary); }
/* Contador de órdenes pendientes en el botón de nav (pill a la derecha). */
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
  background: var(--primary); color: var(--primary-ink, #07101f); line-height: 1; }

/* Sidebar footer (user + theme) */
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  font-weight: 700; font-size: 12px; color: var(--primary-ink); background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.sidebar-user .who { display: grid; line-height: 1.25; min-width: 0; }
.sidebar-user .who small { color: var(--text-soft); font-size: 11px; }
.sidebar-user .who strong { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { margin-left: auto; display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--text-soft); cursor: pointer;
  transition: all 120ms ease; }
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }

/* Theme panel */
.theme-panel { position: absolute; bottom: calc(100% + 8px); right: 0; z-index: 20; min-width: 184px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: 12px; box-shadow: var(--shadow-md); }
.theme-title { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-soft); margin-bottom: 8px; }
.theme-options { display: flex; flex-wrap: wrap; gap: 7px; }
.theme-option { width: 26px; height: 26px; border-radius: 50%; border: 2px solid; cursor: pointer; transition: transform 120ms ease; }
.theme-option:hover { transform: scale(1.12); }
.theme-option.active { outline: 2px solid var(--text); outline-offset: 2px; }

/* ============================================================
   Content / topbar
   ============================================================ */
.content { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-main) 80%, transparent); backdrop-filter: blur(10px); }
.topbar .eyebrow { margin: 0; color: var(--text-soft); font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; }
.topbar h1 { font-size: 21px; margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
/* El bloque izquierdo (☰ + título) no debe envolver ni empujar las acciones. */
.topbar > .flex { flex-wrap: nowrap; min-width: 0; flex: 1 1 auto; }
.topbar > .flex > div { min-width: 0; }
.topbar .menu-toggle { margin-left: 0; }
.topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page { padding: 24px; display: none; }
.page.is-visible { display: block; animation: fade-in 200ms ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { margin-bottom: 18px; }
.page-head h2 { font-size: 19px; }
.page-subtitle { margin: 4px 0 0; color: var(--text-soft); font-size: 13.5px; }

.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h3 { font-size: 15px; }
.section-head .sub { color: var(--text-soft); font-size: 12.5px; margin: 2px 0 0; }

/* ============================================================
   Cards & grids
   ============================================================ */
.grid { display: grid; gap: var(--gap); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  padding: 18px; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 15px; }
.card-title { display: flex; align-items: center; gap: 9px; font-size: 15px; font-family: var(--font-head); font-weight: 700; }
/* Tamaño base de los logos SVG de exchange para CUALQUIER contexto (tablas, celdas, etc.);
   sin esto un <svg> sin width/height se estira a todo el ancho. Los contextos específicos
   de abajo lo pueden agrandar porque tienen más especificidad. */
.ex-logo { height: 20px; width: auto; flex-shrink: 0; vertical-align: middle; }
.card-title .ex-logo { height: 22px; width: auto; flex-shrink: 0; }

/* KPI stat card */
.stat { display: flex; flex-direction: column; gap: 10px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { color: var(--text-soft); font-size: 12.5px; font-weight: 600; }
.stat-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--primary-soft); color: var(--primary); font-size: 16px; }
.stat-value { font-family: var(--font-head); font-weight: 700; font-size: 26px; line-height: 1; }
.stat-sub { color: var(--text-soft); font-size: 12px; }

/* Definition list inside cards */
.dl { display: grid; gap: 1px; }
.dl .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 2px;
  border-bottom: 1px solid var(--line); }
.dl .row:last-child { border-bottom: 0; }
.dl .row span { color: var(--text-soft); font-size: 13px; }
.dl .row strong { font-weight: 700; font-size: 14px; text-align: right; }
/* Variante compacta: detalles más chicos para dar más lugar al chat. */
.dl--compact .row { padding: 4px 2px; }
.dl--compact .row span { font-size: 12px; }
.dl--compact .row strong { font-size: 12.5px; }

/* Exchange connect card */
.ex-card { display: flex; flex-direction: column; gap: 12px; cursor: pointer; transition: border-color 120ms ease, transform 120ms ease; }
.ex-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.ex-card.is-soon { opacity: 0.55; cursor: default; }
.ex-card.is-soon:hover { border-color: var(--line); transform: none; }
.ex-card .ex-top { display: flex; align-items: center; gap: 10px; }
.ex-card .ex-logo { height: 26px; width: auto; flex-shrink: 0; }
.ex-card .ex-name { font-family: var(--font-head); font-weight: 700; font-size: 16px; }
.ex-card .ex-foot { display: flex; align-items: center; justify-content: space-between; }
.ex-order-item .ex-logo { height: 22px; width: auto; flex-shrink: 0; }

/* ============================================================
   Buttons
   ============================================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent;
  border-radius: var(--r-sm); padding: 9px 15px; font-family: var(--font-body); font-size: 13.5px; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: filter 120ms ease, background 120ms ease, border-color 120ms ease, color 120ms ease; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-ink); }
.btn--primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--surface-hover); }
.btn--good { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.btn--good:hover { background: color-mix(in srgb, var(--good) 26%, transparent); }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 26%, transparent); }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.btn--icon { padding: 7px 9px; }
.btn--block { width: 100%; }
.btn.is-on { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, transparent); }

/* ============================================================
   Forms
   ============================================================ */
.field { display: grid; gap: 6px; }
.field > label, label.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
input, select, textarea { width: 100%; font: inherit; color: var(--text); padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--bg-soft);
  transition: border-color 120ms ease, box-shadow 120ms ease; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--text-soft) 80%, transparent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 72px; }
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2395a3c0' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }
.form-grid { display: grid; gap: 12px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-row > .field { flex: 1; min-width: 130px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background 150ms ease; }
.switch .track::before { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform 150ms ease; box-shadow: var(--shadow-sm); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::before { transform: translateX(18px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; }
.switch-row .label { font-size: 13.5px; font-weight: 600; }
.switch-row .desc { color: var(--text-soft); font-size: 12px; margin-top: 2px; }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-md); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { position: sticky; top: 0; text-align: left; padding: 11px 14px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-soft);
  background: var(--surface-2); border-bottom: 1px solid var(--line); }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 100ms ease; }
tbody tr:hover { background: var(--surface-hover); }
td .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ============================================================
   Badges / pills
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: var(--r-pill); padding: 4px 10px;
  font-size: 11.5px; font-weight: 700; border: 1px solid; white-space: nowrap; }
.badge--ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: var(--good-soft); }
.badge--warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }
.badge--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.badge--mute { color: var(--text-soft); border-color: var(--line-strong); background: var(--surface-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot--ok { background: var(--good); } .dot--warn { background: var(--warn); } .dot--mute { background: var(--text-soft); }

/* Semáforo de riesgo de contraparte */
.risk-dot { font-size: 9px; vertical-align: middle; cursor: help; }
.risk-banner { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 12.5px; }
.risk-banner ul { margin: 4px 0 0; padding-left: 18px; }
.risk-banner--warn { color: var(--warn); background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
.risk-banner--danger { color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }

/* ============================================================
   Empty / loading states
   ============================================================ */
.empty { display: grid; place-items: center; gap: 8px; padding: 34px 16px; text-align: center; color: var(--text-soft); }
.empty i { font-size: 26px; opacity: 0.6; }
.empty .t { font-weight: 700; color: var(--text); font-size: 14px; }
.empty .d { font-size: 13px; }

.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 8%, transparent), transparent);
  transform: translateX(-100%); animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 9px 0; }
.sk-card { height: 96px; }

/* ============================================================
   Toast
   ============================================================ */
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 200; max-width: 340px;
  display: flex; align-items: center; gap: 9px; padding: 12px 15px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.toast.is-visible { opacity: 1; transform: none; }
.toast.is-err { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.toast.is-ok { border-color: color-mix(in srgb, var(--good) 50%, transparent); }

/* ============================================================
   Confirm dialog (overlay propio)
   ============================================================ */
.confirm-overlay { position: fixed; inset: 0; z-index: 130; display: none; place-items: center; padding: 20px;
  background: rgba(2, 6, 14, 0.7); backdrop-filter: blur(6px); }
.confirm-overlay.is-open { display: grid; animation: fade-in 140ms ease; }
.confirm-box { width: min(380px, 100%); border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); padding: 22px; box-shadow: var(--shadow-lg); display: grid; gap: 8px; }
.confirm-box h3 { font-size: 17px; }
.confirm-box p { font-size: 13.5px; margin: 0; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* ============================================================
   Lightbox (imagen de chat ampliada)
   ============================================================ */
.lightbox { position: fixed; inset: 0; z-index: 120; display: none; place-items: center; padding: 28px;
  background: rgba(2, 6, 14, 0.8); backdrop-filter: blur(8px); cursor: zoom-out; }
.lightbox.is-open { display: grid; animation: fade-in 140ms ease; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 12px; box-shadow: var(--shadow-lg);
  cursor: default; animation: fade-in 160ms ease; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay { position: fixed; inset: 0; z-index: 90; display: none; place-items: center; padding: 20px;
  background: rgba(2, 6, 14, 0.62); backdrop-filter: blur(5px); }
.modal-overlay.is-open { display: grid; animation: fade-in 140ms ease; }
.modal-box { width: min(500px, 100%); max-height: 90vh; overflow-y: auto; border: 1px solid var(--line);
  border-radius: var(--r-xl); background: var(--surface); padding: 22px; box-shadow: var(--shadow-lg); }
/* Variante ancha (modal de órdenes): más ancho en PC; en móvil queda 100% igual. */
.modal-box--wide { width: min(860px, 100%); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h3 { font-size: 17px; }
.modal-close { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-soft); font-size: 18px; cursor: pointer; }
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ============================================================
   Helpers
   ============================================================ */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gap-sm { gap: 7px; }
.mt-1 { margin-top: 10px; } .mt-2 { margin-top: 18px; }
.text-soft { color: var(--text-soft); }
.text-good { color: var(--good); } .text-danger { color: var(--danger); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; }
.qr-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }
/* Métodos de pago en Mercado: que los badges envuelvan (no desborden, sobre todo en móvil). */
.mkt-pays { display: inline-flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 100%; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 270px; transform: translateX(-100%);
    transition: transform 200ms ease; box-shadow: var(--shadow-lg); height: 100dvh; }
  .sidebar.is-open { transform: none; }
  .menu-toggle { display: grid !important; }
}
@media (min-width: 861px) { .menu-toggle { display: none; } }
@media (max-width: 640px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .page, .topbar { padding-left: 16px; padding-right: 16px; }
  .topbar { padding-top: 12px; padding-bottom: 12px; gap: 8px; }
  .topbar h1 { font-size: 18px; }
  .topbar .eyebrow { display: none; }
  .topbar-actions { gap: 6px; }
  .hide-sm { display: none; }
  /* iOS hace zoom automático al enfocar un campo con letra <16px (descuadra la pantalla);
     forzar 16px en móvil lo evita. */
  input, select, textarea { font-size: 16px; }

  /* Tablas responsive: en móvil cada fila se apila como tarjeta (clave: valor). */
  .table-wrap table { min-width: 0; }
  .table-wrap thead { display: none; }
  .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
    margin-bottom: 10px; padding: 4px 2px; }
  .table-wrap tr:last-child { margin-bottom: 0; }
  .table-wrap td { display: flex; align-items: center; justify-content: space-between; gap: 14px;
    border: 0; padding: 8px 12px; text-align: right; flex-wrap: wrap; }
  .table-wrap td::before { content: attr(data-label); color: var(--text-soft); font-weight: 600;
    text-align: left; white-space: nowrap; }
  .table-wrap td:last-child { justify-content: flex-end; }
  .table-wrap td:empty { display: none; }
}

/* --- Multi-cuenta: selector de perfil + modal de gestión --- */
.profile-switcher { display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-soft); }
.profile-switcher .bi { font-size: 14px; }
.profile-select { background: transparent; color: var(--text); border: 0; outline: 0;
  font: inherit; font-size: 13px; font-weight: 600; max-width: 160px; cursor: pointer; }
.profile-select option { background: var(--bg-soft); color: var(--text); }
.prof-list { display: flex; flex-direction: column; gap: 8px; }
.prof-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); flex-wrap: wrap; }
.prof-row__main { min-width: 0; line-height: 1.5; }
.prof-row__act { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* --- Páginas legales (términos / privacidad) --- */
.legal-doc { max-width: 820px; margin: 0 auto; padding: 32px 20px 64px; line-height: 1.65; }
.legal-doc h1 { font-size: 26px; margin: 0 0 6px; }
.legal-doc h2 { font-size: 17px; margin: 26px 0 8px; }
.legal-doc p, .legal-doc li { color: var(--text); font-size: 14.5px; }
.legal-doc ul { margin: 0 0 8px; padding-left: 20px; display: grid; gap: 6px; }
.legal-doc a { color: var(--primary); }
.legal-meta { color: var(--text-soft); font-size: 13px; }
.landing-foot-links { font-size: 13px; }
.landing-foot-links a { color: var(--text-soft); }
.landing-foot-links a:hover { color: var(--primary); }

/* --- Landing: preview del hero + franja de stats + CTA final --- */
.hero-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 30px auto 0; max-width: 760px; }
.hp-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 16px; text-align: left; display: flex; flex-direction: column; gap: 3px; }
.hp-card i { font-size: 22px; color: var(--primary); margin-bottom: 4px; }
.hp-card b { font-size: 14.5px; }
.hp-card span { font-size: 12.5px; color: var(--text-soft); }
.hp-card--accent { border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
  box-shadow: 0 0 0 1px var(--primary-soft) inset; }

.landing-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; max-width: 880px; margin: 44px auto 4px; }
.lstat { text-align: center; padding: 16px 10px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.lstat b { display: block; font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.lstat span { font-size: 12.5px; color: var(--text-soft); }

.landing-cta { text-align: center; padding: 42px 22px; margin: 8px auto 0; max-width: 720px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); }
.landing-cta h2 { font-size: 24px; margin: 0 0 6px; }
.landing-cta p { color: var(--text-soft); margin: 0 0 18px; }
.landing-cta .hero-cta { justify-content: center; }

@media (max-width: 720px) {
  .hero-preview { grid-template-columns: 1fr; max-width: 380px; }
  .landing-stats { grid-template-columns: repeat(2, 1fr); }
}
