/* ═══════════════════════════════════════════════════════
   AP-SNEAT — Theme único Agro Parallel OS (estilo Sneat)
   Sin dependencias externas. Self-contained.
   Paleta: verde AgroParallel + naranja acento + dark navy sidebar.
═══════════════════════════════════════════════════════ */

/* Fuentes self-hosted (antes en fonts.googleapis.com).
   Public Sans es variable: el mismo woff2 sirve para 400/500/600/700.
   JetBrains Mono solo aparece en el chat WhatsApp. */
@font-face {
  font-family: 'Public Sans';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('/public/fonts/public-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Public Sans';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('/public/fonts/public-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Public Sans';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('/public/fonts/public-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Public Sans';
  font-style: normal; font-weight: 700; font-display: swap;
  src: url('/public/fonts/public-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext: caracteres adicionales (ç ã etc.) */
@font-face {
  font-family: 'Public Sans';
  font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/public/fonts/public-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal; font-weight: 400 500; font-display: swap;
  src: url('/public/fonts/jetbrains-mono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Paleta de marca */
  --ap-primary: #3d9c1e;
  --ap-primary-dark: #2a6d13;
  --ap-primary-light: #5bbf35;
  --ap-primary-glow: rgba(61,156,30,.20);
  --ap-primary-pale: rgba(61,156,30,.08);

  --ap-accent: #f59e0b;
  --ap-accent-dark: #d97706;
  --ap-accent-pale: rgba(245,158,11,.10);

  --ap-info:    #4a9edd;
  --ap-success: #5bbf35;
  --ap-warning: #e0a832;
  --ap-danger:  #e05252;
  --ap-purple:  #9b6dd6;

  /* Light theme (default) */
  --ap-body-bg: #e9ecf2;
  --ap-surface: #ffffff;
  --ap-surface-2: #f3f5f9;
  --ap-border: #d9dde5;
  --ap-text: #2f3441;
  --ap-text-muted: #6b7585;
  --ap-text-dim: #a3acba;
  --ap-shadow: 0 .25rem 1rem rgba(50,55,70,.10), 0 1px 2px rgba(50,55,70,.06);
  --ap-shadow-hover: 0 .5rem 1.75rem rgba(50,55,70,.18);

  /* Sidebar dark navy (estilo Sneat semi-dark) */
  --ap-sidebar-bg: #2f3349;
  --ap-sidebar-bg-active: #383d59;
  --ap-sidebar-text: #cbcde0;
  --ap-sidebar-text-muted: #7f87a3;
  --ap-sidebar-border: rgba(255,255,255,.06);

  /* Métricas */
  --ap-sidebar-w: 260px;
  --ap-topbar-h: 64px;
  --ap-radius: 10px;
  --ap-radius-sm: 6px;
}

/* ── Reset y base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ap-text);
  background: var(--ap-body-bg);
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,h5,h6 { margin: 0 0 .5rem; color: var(--ap-text); font-weight: 600; }
h1 { font-size: 1.625rem; }  h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }  h4 { font-size: 1rem; }
h5 { font-size: .9375rem; }  h6 { font-size: .8125rem; }
p { margin: 0 0 .75rem; }
a { color: var(--ap-primary); text-decoration: none; }
a:hover { color: var(--ap-primary-dark); }
hr { border: 0; border-top: 1px solid var(--ap-border); margin: 1rem 0; }
small { font-size: .8125rem; color: var(--ap-text-muted); }
code { background: var(--ap-surface-2); padding: .125rem .375rem; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: .85em; }

/* ── Layout principal: sidebar + main ─────────────────── */
.ap-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────── */
.ap-sidebar {
  width: var(--ap-sidebar-w);
  background: var(--ap-sidebar-bg);
  color: var(--ap-sidebar-text);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
  transition: transform .25s ease;
}
.ap-sidebar::-webkit-scrollbar { width: 6px; }
.ap-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

.ap-sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--ap-sidebar-border);
  text-decoration: none;
  color: #fff;
}
.ap-sidebar-brand .ap-brand-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--ap-primary-dark), var(--ap-primary));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px var(--ap-primary-glow);
}
.ap-sidebar-brand .ap-brand-text {
  font-weight: 800; letter-spacing: 1px; font-size: 16px; color: #fff;
}
.ap-sidebar-brand .ap-brand-text span { color: var(--ap-primary-light); }
.ap-sidebar-brand .ap-brand-sub { font-size: 10px; letter-spacing: 2px; color: var(--ap-sidebar-text-muted); }

.ap-sidebar-section {
  padding: 14px 20px 4px;
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--ap-sidebar-text-muted);
}
.ap-sidebar-item {
  display: flex; align-items: center; gap: 12px;
  margin: 1px 12px;
  padding: 8px 14px;
  border-radius: var(--ap-radius-sm);
  color: var(--ap-sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
  cursor: pointer;
}
.ap-sidebar-item:hover {
  background: rgba(255,255,255,.05);
  color: #fff;
}
.ap-sidebar-item.active {
  background: linear-gradient(270deg, var(--ap-primary), var(--ap-primary-dark));
  color: #fff;
  box-shadow: 0 2px 8px var(--ap-primary-glow);
}
.ap-sidebar-item .ap-icon { width: 18px; text-align: center; font-size: 16px; flex-shrink: 0; }
.ap-sidebar-item .ap-badge { margin-left: auto; }

.ap-sidebar-footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--ap-sidebar-border);
  font-size: 11px;
  color: var(--ap-sidebar-text-muted);
}
.ap-sidebar-footer a { color: var(--ap-sidebar-text-muted); }
.ap-sidebar-footer a:hover { color: var(--ap-primary-light); }

/* ── Main column ─────────────────────────────────────── */
.ap-main {
  margin-left: var(--ap-sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column;
}

/* ── Topbar ──────────────────────────────────────────── */
.ap-topbar {
  height: var(--ap-topbar-h);
  background: var(--ap-surface);
  border-bottom: 1px solid var(--ap-border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.ap-topbar-title { font-size: 18px; font-weight: 600; color: var(--ap-text); }
.ap-topbar-sub   { font-size: 13px; color: var(--ap-text-muted); }
.ap-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.ap-burger { display:none; background:transparent; border:none; padding:6px 10px; color:var(--ap-text); cursor:pointer; font-size:20px;}

.ap-user-dropdown {
  position: relative;
}
.ap-user-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  background: transparent; border: none; cursor: pointer;
  border-radius: var(--ap-radius);
  color: var(--ap-text);
}
.ap-user-btn:hover { background: var(--ap-surface-2); }
.ap-user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--ap-primary), var(--ap-primary-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600;
}
.ap-user-name { font-size: 13.5px; font-weight: 500; }
.ap-user-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow-hover);
  min-width: 220px;
  padding: 6px;
  display: none;
  z-index: 60;
}
.ap-user-dropdown.open .ap-user-menu { display: block; }
.ap-user-menu a, .ap-user-menu button {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--ap-radius-sm);
  color: var(--ap-text); text-decoration: none;
  background: transparent; border: none; width: 100%; text-align: left;
  font-size: 13.5px; cursor: pointer;
  font-family: inherit;
}
.ap-user-menu a:hover, .ap-user-menu button:hover { background: var(--ap-surface-2); }
.ap-user-menu hr { margin: 4px 0; }

/* ── Content area ─────────────────────────────────────── */
.ap-content {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ap-content > * { min-height: 0; }
.ap-content-narrow { max-width: 1400px; margin: 0 auto; }

/* ── Card ─────────────────────────────────────────────── */
.ap-card {
  background: var(--ap-surface);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
  margin-bottom: 24px;
  overflow: hidden;
}
.ap-card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--ap-border);
  display: flex; align-items: center; gap: 12px;
}
.ap-card-header h3 { margin: 0; flex: 1; font-size: 16px; }
.ap-card-body { padding: 24px; }
.ap-card-footer { padding: 14px 24px; border-top: 1px solid var(--ap-border); background: var(--ap-surface-2); }
.ap-card.danger { border-left: 3px solid var(--ap-danger); }
.ap-card.warn   { border-left: 3px solid var(--ap-warning); }
.ap-card.info   { border-left: 3px solid var(--ap-info); }
.ap-card.ok     { border-left: 3px solid var(--ap-success); }

/* ── KPI / Stat card ──────────────────────────────────── */
.ap-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 24px; }
.ap-stat {
  background: var(--ap-surface);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
  padding: 20px 22px;
  position: relative;
}
.ap-stat-label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ap-text-muted); }
.ap-stat-value { font-size: 28px; font-weight: 700; color: var(--ap-text); margin-top: 6px; line-height: 1.1; }
.ap-stat-delta { font-size: 12px; color: var(--ap-text-muted); margin-top: 4px; }
.ap-stat-delta.up    { color: var(--ap-success); }
.ap-stat-delta.down  { color: var(--ap-danger); }
.ap-stat-icon {
  position: absolute; top: 18px; right: 18px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--ap-radius);
  background: var(--ap-primary-pale);
  color: var(--ap-primary);
  font-size: 18px;
}
.ap-stat.accent .ap-stat-icon { background: var(--ap-accent-pale); color: var(--ap-accent); }
.ap-stat.info   .ap-stat-icon { background: rgba(74,158,221,.12);  color: var(--ap-info); }
.ap-stat.warn   .ap-stat-icon { background: rgba(224,168,50,.12);  color: var(--ap-warning); }
.ap-stat.danger .ap-stat-icon { background: rgba(224,82,82,.12);   color: var(--ap-danger); }

/* ── Buttons ──────────────────────────────────────────── */
.ap-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--ap-radius-sm);
  font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: opacity .15s ease, transform .05s ease;
  white-space: nowrap;
}
.ap-btn:hover { opacity: .88; }
.ap-btn:active { transform: translateY(1px); }
.ap-btn.primary  { background: var(--ap-primary); color: #fff; border-color: var(--ap-primary); }
.ap-btn.accent   { background: var(--ap-accent);  color: #fff; border-color: var(--ap-accent); }
.ap-btn.success  { background: var(--ap-success); color: #fff; }
.ap-btn.warn     { background: var(--ap-warning); color: #fff; }
.ap-btn.danger   { background: var(--ap-danger);  color: #fff; }
.ap-btn.info     { background: var(--ap-info);    color: #fff; }
.ap-btn.ghost    { background: transparent; color: var(--ap-text); border-color: var(--ap-border); }
.ap-btn.ghost:hover { background: var(--ap-surface-2); }
.ap-btn.outline  { background: transparent; color: var(--ap-primary); border-color: var(--ap-primary); }
.ap-btn.outline:hover { background: var(--ap-primary-pale); }
.ap-btn.sm { padding: 5px 12px; font-size: 12px; }
.ap-btn.lg { padding: 10px 20px; font-size: 15px; }
.ap-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────────── */
.ap-form-group { margin-bottom: 16px; }
.ap-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ap-text);
  margin-bottom: 6px;
}
.ap-input, .ap-select, .ap-textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ap-text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ap-input:focus, .ap-select:focus, .ap-textarea:focus {
  outline: none;
  border-color: var(--ap-primary);
  box-shadow: 0 0 0 3px var(--ap-primary-pale);
}
.ap-textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.ap-help { font-size: 11.5px; color: var(--ap-text-muted); margin-top: 4px; }

.ap-row { display: grid; gap: 14px; }
.ap-row-2 { grid-template-columns: 1fr 1fr; }
.ap-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.ap-row-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) { .ap-row-2, .ap-row-3, .ap-row-4 { grid-template-columns: 1fr; } }

/* ── Tables ───────────────────────────────────────────── */
.ap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.ap-table thead th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ap-text-muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--ap-border);
  background: var(--ap-surface-2);
}
.ap-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--ap-border);
  color: var(--ap-text);
}
.ap-table tbody tr:hover { background: var(--ap-surface-2); }
.ap-table tbody tr:last-child td { border-bottom: none; }
.ap-table .r { text-align: right; }
.ap-table .c { text-align: center; }

/* ── Badges ───────────────────────────────────────────── */
.ap-badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .25px;
}
.ap-badge.primary  { background: var(--ap-primary-pale);  color: var(--ap-primary-dark); }
.ap-badge.accent   { background: var(--ap-accent-pale);   color: var(--ap-accent-dark); }
.ap-badge.info     { background: rgba(74,158,221,.14);    color: var(--ap-info); }
.ap-badge.success  { background: rgba(91,191,53,.18);     color: #3d9c1e; }
.ap-badge.warn     { background: rgba(224,168,50,.18);    color: #b07a18; }
.ap-badge.danger   { background: rgba(224,82,82,.14);     color: var(--ap-danger); }
.ap-badge.muted    { background: var(--ap-surface-2);     color: var(--ap-text-muted); }
.ap-badge.solid    { background: var(--ap-primary);       color: #fff; }
.ap-badge.dot { width: 8px; height: 8px; padding: 0; border-radius: 50%; }

/* ── Dialog / Modal ───────────────────────────────────── */
dialog.ap-dialog { border: none; background: transparent; padding: 0; max-width: 760px; width: 92%; }
dialog.ap-dialog::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
.ap-dialog-inner {
  background: var(--ap-surface);
  border-radius: var(--ap-radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.30);
  max-height: 90vh; overflow: auto;
}
.ap-dialog-header { padding: 18px 24px; border-bottom: 1px solid var(--ap-border); display: flex; align-items: center; }
.ap-dialog-header h2 { margin: 0; flex: 1; font-size: 17px; }
.ap-dialog-header .ap-close {
  background: transparent; border: none; color: var(--ap-text-muted);
  font-size: 22px; cursor: pointer; padding: 0 4px;
}
.ap-dialog-header .ap-close:hover { color: var(--ap-text); }
.ap-dialog-body { padding: 22px 24px; }
.ap-dialog-footer { padding: 14px 24px; border-top: 1px solid var(--ap-border); background: var(--ap-surface-2); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Tabs ─────────────────────────────────────────────── */
.ap-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ap-border); margin-bottom: 20px; }
.ap-tab {
  padding: 10px 18px;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--ap-text-muted);
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  margin-bottom: -1px;
}
.ap-tab:hover { color: var(--ap-text); }
.ap-tab.active { color: var(--ap-primary); border-bottom-color: var(--ap-primary); }

/* ── Alerts / toast ───────────────────────────────────── */
.ap-alert {
  padding: 12px 16px;
  border-radius: var(--ap-radius-sm);
  background: var(--ap-primary-pale);
  border-left: 4px solid var(--ap-primary);
  color: var(--ap-primary-dark);
  margin-bottom: 16px;
  font-size: 13.5px;
}
.ap-alert.accent  { background: var(--ap-accent-pale); border-left-color: var(--ap-accent); color: var(--ap-accent-dark); }
.ap-alert.warn    { background: rgba(224,168,50,.14); border-left-color: var(--ap-warning); color: #8a5f18; }
.ap-alert.danger  { background: rgba(224,82,82,.10); border-left-color: var(--ap-danger); color: #a83838; }
.ap-alert.info    { background: rgba(74,158,221,.10); border-left-color: var(--ap-info); color: #2a6a9d; }
.ap-alert.success { background: rgba(91,191,53,.10); border-left-color: var(--ap-success); color: #2a6d13; }

.ap-toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: var(--ap-surface);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow-hover);
  padding: 14px 20px;
  border-left: 4px solid var(--ap-primary);
  font-size: 13.5px;
  min-width: 240px;
  animation: ap-slide-in .25s ease;
}
.ap-toast.success { border-left-color: var(--ap-success); }
.ap-toast.danger,
.ap-toast.err     { border-left-color: var(--ap-danger); }
.ap-toast.warn    { border-left-color: var(--ap-warning); }
@keyframes ap-slide-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Empty state ──────────────────────────────────────── */
.ap-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--ap-text-muted);
  border: 1px dashed var(--ap-border);
  border-radius: var(--ap-radius);
  background: var(--ap-surface);
}
.ap-empty .ap-empty-icon { font-size: 36px; margin-bottom: 12px; opacity: .5; }

/* ── Utilities ────────────────────────────────────────── */
.ap-flex      { display: flex; }
.ap-flex-col  { display: flex; flex-direction: column; }
.ap-items-center { align-items: center; }
.ap-justify-between { justify-content: space-between; }
.ap-justify-end { justify-content: flex-end; }
.ap-gap-1 { gap: 4px; }   .ap-gap-2 { gap: 8px; }
.ap-gap-3 { gap: 12px; }  .ap-gap-4 { gap: 16px; }
.ap-mb-0  { margin-bottom: 0; }   .ap-mb-1  { margin-bottom: 4px; }
.ap-mb-2  { margin-bottom: 8px; } .ap-mb-3  { margin-bottom: 12px; }
.ap-mb-4  { margin-bottom: 16px; }.ap-mb-6  { margin-bottom: 24px; }
.ap-mt-0  { margin-top: 0; }      .ap-mt-2  { margin-top: 8px; }
.ap-mt-4  { margin-top: 16px; }   .ap-mt-6  { margin-top: 24px; }
.ap-text-sm { font-size: 12px; }
.ap-text-muted { color: var(--ap-text-muted); }
.ap-text-right { text-align: right; }
.ap-text-center { text-align: center; }
.ap-text-bold { font-weight: 600; }
.ap-w-full { width: 100%; }
.ap-grow { flex: 1; }
.ap-hidden { display: none !important; }

/* ── Login / pages sin shell ──────────────────────────── */
.ap-auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--ap-surface-2), var(--ap-body-bg));
}
.ap-auth-card {
  background: var(--ap-surface);
  border-radius: var(--ap-radius);
  box-shadow: 0 12px 32px rgba(75,70,92,.15);
  max-width: 440px; width: 100%;
  padding: 32px;
}

/* ── Responsive (móvil) ───────────────────────────────── */
@media (max-width: 980px) {
  .ap-burger { display: inline-flex; }
  .ap-sidebar { transform: translateX(-100%); }
  .ap-sidebar.open { transform: translateX(0); }
  .ap-main { margin-left: 0; }
  .ap-content { padding: 16px; }
  .ap-stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  .ap-stats { grid-template-columns: 1fr; }
  .ap-topbar { padding: 0 14px; }
  .ap-user-name { display: none; }
}

/* ── Dark mode (auto-prefers) ────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --ap-body-bg: #232333;
    --ap-surface: #2b2c40;
    --ap-surface-2: #353651;
    --ap-border: #43455b;
    --ap-text: #cbcde0;
    --ap-text-muted: #8592a3;
    --ap-text-dim: #5f6582;
    --ap-shadow: 0 .25rem 1.125rem rgba(0,0,0,.30);
    --ap-shadow-hover: 0 .5rem 1.75rem rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  --ap-body-bg: #232333;
  --ap-surface: #2b2c40;
  --ap-surface-2: #353651;
  --ap-border: #43455b;
  --ap-text: #cbcde0;
  --ap-text-muted: #8592a3;
  --ap-text-dim: #5f6582;
  --ap-shadow: 0 .25rem 1.125rem rgba(0,0,0,.30);
  --ap-shadow-hover: 0 .5rem 1.75rem rgba(0,0,0,.45);
}

/* ═══════════════════════════════════════════════════════════
   COMPAT MOBILE — Reset responsive para módulos migrados
   Los módulos viejos se construyeron como dashboards de
   pantalla completa (split list/detail, grids 2-3 col, etc.).
   En mobile colapsamos esas estructuras a 1 columna.
═══════════════════════════════════════════════════════════ */
@media (max-width: 980px) {
  /* Splits horizontales (clientes, proveedores, ordenes, etc.)
     deben apilarse vertical en mobile */
  .ap-content .content,
  .ap-content .layout-split {
    flex-direction: column !important;
    overflow: visible !important;
    height: auto !important;
  }
  .ap-content .list-col,
  .ap-content .lista-col,
  .ap-content .panel-left,
  .ap-content .left-pane {
    width: 100% !important;
    flex-basis: auto !important;
    flex-shrink: 1 !important;
    border-right: none !important;
    border-bottom: 1px solid var(--ap-border);
    max-height: 60vh;
  }
  .ap-content .detail-col,
  .ap-content .detalle-col,
  .ap-content .panel-right,
  .ap-content .right-pane {
    width: 100% !important;
    flex-basis: auto !important;
    min-height: 40vh;
  }
  /* Nota: el ocultar detail-col cuando no hay selección se maneja
     desde JS de cada módulo (toggling display de .no-selection /
     #clienteDetalle). No usamos :has() porque depende de inline
     style que el selector no puede detectar. */

  /* Grids comunes a 1 columna */
  .ap-content .info-grid,
  .ap-content .grid-2,
  .ap-content .grid-3,
  .ap-content .grid-4,
  .ap-content .form-grid,
  .ap-content .form-row,
  .ap-content .finance-strip,
  .ap-content .stats-row,
  .ap-content .kpi-row,
  .ap-content .tabs-grid {
    grid-template-columns: 1fr !important;
    display: grid !important;
  }

  /* Tablas con scroll horizontal */
  .ap-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    max-width: 100%;
  }
  .ap-content .table-wrap,
  .ap-content .tabla-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Toolbars y filtros: wrap */
  .ap-content .toolbar,
  .ap-content .list-toolbar,
  .ap-content .filter-row,
  .ap-content .actions-row,
  .ap-content .botonera {
    flex-wrap: wrap !important;
  }

  /* Dialogs: full-screen friendly */
  .ap-content dialog, dialog.ap-dialog, .ap-content .modal {
    width: calc(100vw - 24px) !important;
    max-width: 100% !important;
    margin: 12px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
  }

  /* Tipografía un poco más chica */
  .ap-content h1 { font-size: 22px; }
  .ap-content h2 { font-size: 18px; }
  .ap-content h3 { font-size: 16px; }

  /* Inputs con altura cómoda para touch */
  .ap-content input:not([type=checkbox]):not([type=radio]):not([type=color]),
  .ap-content select,
  .ap-content textarea,
  .ap-content button {
    min-height: 40px;
  }
}

@media (max-width: 540px) {
  .ap-content { padding: 12px !important; }
  .ap-content .info-card,
  .ap-content .card,
  .ap-content .panel { padding: 12px !important; }
  /* Topbar más compacta */
  .ap-topbar { padding: 0 12px; gap: 8px; }
  .ap-topbar-title { font-size: 15px; }
  .ap-topbar-sub   { font-size: 11px; }
}
