/* ============================================================
   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; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(800px 500px at 50% -10%, var(--bg-gradient-2), transparent 60%), var(--bg-main); }
.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; }
.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; }
}
