/* ═══════════════════════════════════════════════════════════
   ESTUATA — Design System v4
   Estética: Industrial Precision × Organic Warmth
   Paleta: Deep Forest + Warm Ink + Citric Flash
   Tipografía: DM Serif Display + Plus Jakarta Sans
   Motivo: Importación premium, no startup genérica
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── TOKENS LIGHT ── */
:root {
  /* Paleta base — tinta cálida */
  --c-bg:         #f5f3ef;
  --c-surface:    #fdfcfa;
  --c-card:       #f0ede8;
  --c-card2:      #e8e4dd;
  --c-border:     rgba(40, 35, 25, 0.09);
  --c-border2:    rgba(40, 35, 25, 0.17);
  --c-text:       #1a1712;
  --c-text2:      #3d3830;
  --c-muted:      #72695a;
  --c-muted2:     #b0a898;
  --c-ph:         #c4bdb0;

  /* Acento primario — Forest ink */
  --c-accent:          #1e5c38;
  --c-accent-mid:      #2a7d4f;
  --c-accent-bright:   #34a862;
  --c-accent-hover:    #174d2f;
  --c-accent-subtle:   rgba(30, 92, 56, 0.07);
  --c-accent-glow:     rgba(30, 92, 56, 0.22);
  --c-brand-gradient:  linear-gradient(135deg, #1e5c38 0%, #2a7d4f 60%, #34a862 100%);

  /* Flash accent — Citric yellow (para highlights clave) */
  --c-flash:           #d4a017;
  --c-flash-bg:        rgba(212, 160, 23, 0.08);
  --c-flash-border:    rgba(212, 160, 23, 0.25);

  /* Semánticos */
  --c-success:         #1e5c38;
  --c-success-bg:      rgba(30, 92, 56, 0.07);
  --c-success-border:  rgba(30, 92, 56, 0.20);
  --c-warning:         #a05a10;
  --c-warning-bg:      rgba(160, 90, 16, 0.08);
  --c-warning-border:  rgba(160, 90, 16, 0.22);
  --c-danger:          #b02020;
  --c-danger-bg:       rgba(176, 32, 32, 0.07);
  --c-danger-border:   rgba(176, 32, 32, 0.20);
  --c-info:            #1a5070;
  --c-info-bg:         rgba(26, 80, 112, 0.08);
  --c-info-border:     rgba(26, 80, 112, 0.22);
  --c-purple:          #5a3f9e;
  --c-purple-bg:       rgba(90, 63, 158, 0.08);
  --c-purple-border:   rgba(90, 63, 158, 0.22);
  --c-orange:          #a04a18;
  --c-orange-bg:       rgba(160, 74, 24, 0.08);
  --c-orange-border:   rgba(160, 74, 24, 0.22);

  /* Layout */
  --sidebar-w:    260px;
  --topbar-h:     58px;
  --r-sm:   7px;
  --r-md:   12px;
  --r-lg:   18px;
  --r-xl:   24px;
  --r-pill: 999px;

  /* Sombras */
  --sh-xs:  0 1px 2px rgba(26,23,18,0.06);
  --sh-sm:  0 2px 6px rgba(26,23,18,0.08), 0 1px 2px rgba(26,23,18,0.04);
  --sh-md:  0 6px 20px rgba(26,23,18,0.09), 0 2px 6px rgba(26,23,18,0.05);
  --sh-lg:  0 12px 40px rgba(26,23,18,0.11), 0 4px 12px rgba(26,23,18,0.06);
  --sh-xl:  0 24px 64px rgba(26,23,18,0.14), 0 8px 20px rgba(26,23,18,0.07);
  --sh-accent: 0 4px 22px rgba(30, 92, 56, 0.32);
  --sh-inset: inset 0 1px 2px rgba(26,23,18,0.06);

  /* Tipografía */
  --f-display: 'DM Serif Display', Georgia, serif;
  --f-body:    'Plus Jakarta Sans', system-ui, sans-serif;
  --f-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Easing */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --dur:  160ms;
  --dur2: 280ms;
}

/* ── DARK THEME ── */
[data-theme="dark"] {
  --c-bg:         #0d1109;
  --c-surface:    #111508;
  --c-card:       #171d0f;
  --c-card2:      #1e2614;
  --c-border:     rgba(140, 200, 130, 0.09);
  --c-border2:    rgba(140, 200, 130, 0.18);
  --c-text:       #eeeae0;
  --c-text2:      #c0b89e;
  --c-muted:      #7d8c6a;
  --c-muted2:     #3a4530;
  --c-ph:         #4a5c3a;

  --c-accent:          #42c078;
  --c-accent-mid:      #32a060;
  --c-accent-bright:   #52d888;
  --c-accent-hover:    #52d080;
  --c-accent-subtle:   rgba(66, 192, 120, 0.09);
  --c-accent-glow:     rgba(66, 192, 120, 0.25);
  --c-brand-gradient:  linear-gradient(135deg, #1e7040 0%, #2a9a58 60%, #42c078 100%);

  --c-flash:           #e8bc30;
  --c-flash-bg:        rgba(232, 188, 48, 0.09);
  --c-flash-border:    rgba(232, 188, 48, 0.25);

  --c-success:         #42c078;
  --c-success-bg:      rgba(66, 192, 120, 0.09);
  --c-success-border:  rgba(66, 192, 120, 0.25);
  --c-warning:         #d4883a;
  --c-warning-bg:      rgba(212, 136, 58, 0.10);
  --c-warning-border:  rgba(212, 136, 58, 0.25);
  --c-danger:          #e05858;
  --c-danger-bg:       rgba(224, 88, 88, 0.10);
  --c-danger-border:   rgba(224, 88, 88, 0.25);
  --c-info:            #40a8cc;
  --c-info-bg:         rgba(64, 168, 204, 0.10);
  --c-info-border:     rgba(64, 168, 204, 0.25);
  --c-purple:          #9070e0;
  --c-purple-bg:       rgba(144, 112, 224, 0.10);
  --c-purple-border:   rgba(144, 112, 224, 0.25);
  --c-orange:          #d87040;
  --c-orange-bg:       rgba(216, 112, 64, 0.10);
  --c-orange-border:   rgba(216, 112, 64, 0.25);

  --sh-xs:  0 1px 2px rgba(0,0,0,0.20);
  --sh-sm:  0 2px 6px rgba(0,0,0,0.28);
  --sh-md:  0 6px 20px rgba(0,0,0,0.36);
  --sh-lg:  0 12px 40px rgba(0,0,0,0.42);
  --sh-xl:  0 24px 64px rgba(0,0,0,0.50);
  --sh-accent: 0 4px 22px rgba(66, 192, 120, 0.30);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--f-body);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  letter-spacing: 0.005em;
}
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-muted2); }
::selection { background: var(--c-accent); color: white; }
a { color: var(--c-accent); text-decoration: none; transition: color var(--dur); }
a:hover { color: var(--c-accent-mid); }

/* ── KEYFRAMES ── */
@keyframes loadSlide {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(20%); }
  100% { transform: translateX(110%); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes toastSlide {
  from { opacity: 0; transform: translateX(24px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes aipulse {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.6); }
}
@keyframes aidot {
  0%, 100% { opacity: 0.25; transform: scale(0.7); }
  50%       { opacity: 1;   transform: scale(1); }
}
@keyframes shimmer {
  from { background-position: -200% center; }
  to   { background-position: 200% center; }
}
@keyframes ribbonScroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ── AUTH SCREEN ── */
#auth-screen {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
  position: relative;
  overflow: hidden;
}
/* Organic texture orbs */
#auth-screen::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 50% at 80% 10%, rgba(30,92,56,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 10% 90%, rgba(212,160,23,0.06) 0%, transparent 55%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(30,92,56,0.04) 0%, transparent 70%);
}
/* Faint grid */
#auth-screen::after {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(30,92,56,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30,92,56,0.03) 1px, transparent 1px);
  background-size: 32px 32px;
}

[data-theme="dark"] #auth-screen::before {
  background:
    radial-gradient(ellipse 70% 50% at 80% 10%, rgba(66,192,120,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 10% 90%, rgba(232,188,48,0.06) 0%, transparent 55%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(66,192,120,0.04) 0%, transparent 70%);
}
[data-theme="dark"] #auth-screen::after {
  background-image:
    linear-gradient(rgba(66,192,120,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(66,192,120,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
}

.auth-wrap {
  width: 420px; max-width: calc(100vw - 32px);
  position: relative; z-index: 1;
  animation: fadeUp 0.5s var(--ease-out);
}

.auth-brand { text-align: center; margin-bottom: 36px; }
.auth-brand-name {
  font-family: var(--f-display);
  font-size: 40px; letter-spacing: -1px;
  color: var(--c-text);
  /* Subtle shimmer on load */
  background: linear-gradient(90deg, var(--c-text) 30%, var(--c-accent-mid) 50%, var(--c-text) 70%);
  background-size: 200% auto;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear 0.5s 1 forwards;
}
.auth-brand-sub {
  font-size: 11px; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: 3px;
  margin-top: 8px; font-weight: 500;
}

.auth-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: 36px;
  box-shadow: var(--sh-lg), 0 0 0 1px rgba(30,92,56,0.04);
}

.auth-tabs {
  display: flex; gap: 3px;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: calc(var(--r-md) + 2px);
  padding: 4px; margin-bottom: 28px;
}
.auth-tab {
  flex: 1; text-align: center;
  padding: 9px 16px;
  border-radius: var(--r-md);
  cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--c-muted);
  transition: all var(--dur2) var(--ease-out);
  background: none; border: none;
  font-family: var(--f-body); letter-spacing: 0.01em;
}
.auth-tab.on {
  background: var(--c-accent);
  color: white;
  box-shadow: var(--sh-accent);
}
.auth-panel { display: none; flex-direction: column; gap: 14px; }
.auth-panel.on { display: flex; }
.auth-msg { padding: 10px 14px; border-radius: var(--r-sm); font-size: 13px; display: none; }
.auth-msg.err { background: var(--c-danger-bg); border: 1px solid var(--c-danger-border); color: var(--c-danger); }
.auth-msg.ok  { background: var(--c-success-bg); border: 1px solid var(--c-success-border); color: var(--c-success); }

/* ── FORM FIELDS ── */
.f-lbl, .fl {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--c-muted); display: block; margin-bottom: 5px;
}
.f-inp, .fc {
  font-family: var(--f-body); font-size: 14px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  color: var(--c-text);
  padding: 10px 13px;
  border-radius: var(--r-sm); outline: none;
  transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
  width: 100%; line-height: 1.45;
}
.f-inp:focus, .fc:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-subtle);
  background: var(--c-surface);
}
.f-inp::placeholder, .fc::placeholder { color: var(--c-ph); }
.f-inp:hover:not(:focus), .fc:hover:not(:focus) { border-color: var(--c-border2); }

select.fc {
  cursor: pointer; appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2372695a' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
textarea.fc { resize: vertical; min-height: 70px; }

.fg  { display: flex; flex-direction: column; gap: 5px; }
.fg2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fw  { grid-column: 1 / -1; }
.hint { font-size: 11px; color: var(--c-muted2); margin-top: 3px; }

/* ── BUTTONS ── */
.btn {
  font-family: var(--f-body);
  font-size: 13px; font-weight: 600;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  cursor: pointer; border: none;
  transition: all var(--dur) var(--ease-out);
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; position: relative;
  letter-spacing: 0.01em; text-decoration: none;
}
.btn:disabled { opacity: 0.42; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }

.btn-primary {
  background: var(--c-brand-gradient);
  color: white;
  box-shadow: 0 1px 3px rgba(30,92,56,0.22), 0 1px 2px rgba(30,92,56,0.10);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--sh-accent);
  filter: brightness(1.04);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); filter: none; }

.btn-ghost {
  background: transparent; color: var(--c-muted);
  border: 1.5px solid var(--c-border);
}
.btn-ghost:hover { border-color: var(--c-border2); color: var(--c-text2); background: var(--c-card); }
.btn-ghost:active { background: var(--c-card2); }

.btn-danger {
  background: transparent; color: var(--c-danger);
  border: 1.5px solid var(--c-danger-border);
}
.btn-danger:hover { background: var(--c-danger-bg); }

.btn-sm  { font-size: 12px; padding: 6px 12px; }
.btn-xs  { font-size: 11px; padding: 4px 9px; border-radius: 6px; }
.btn-lg  { font-size: 15px; padding: 12px 24px; border-radius: var(--r-md); }
.btn-full { width: 100%; justify-content: center; }

/* ── LAYOUT ── */
#app { display: none; min-height: 100vh; }

/* Sidebar */
nav.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: transform 0.32s var(--ease-out);
}
#sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(26, 23, 18, 0.42);
  opacity: 0; pointer-events: none;
  transition: opacity 0.22s; z-index: 190;
  backdrop-filter: blur(4px);
}
#sidebar-overlay.open { opacity: 1; pointer-events: auto; }

.sb-logo {
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--c-border);
}
.sb-logo-name {
  font-family: var(--f-display);
  font-size: 24px; letter-spacing: -0.5px;
  color: var(--c-text);
}
.sb-logo-sub {
  font-size: 9.5px; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: 2.2px;
  margin-top: 3px; font-weight: 600;
}

.sb-nav { flex: 1; padding: 6px 0; overflow-y: auto; }
.sb-sect {
  padding: 14px 22px 5px;
  font-size: 9.5px; text-transform: uppercase;
  letter-spacing: 2px; color: var(--c-muted2); font-weight: 700;
}
.sb-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px 8px 22px;
  color: var(--c-muted); cursor: pointer;
  transition: all var(--dur) var(--ease-out);
  font-size: 13px; font-weight: 500;
  border-left: 2px solid transparent;
  margin: 1px 10px 1px 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  position: relative;
}
.sb-item:hover {
  color: var(--c-text2);
  background: var(--c-accent-subtle);
}
.sb-item.on {
  background: var(--c-accent-subtle);
  color: var(--c-accent);
  font-weight: 600;
  border-left-color: var(--c-accent);
}
/* Glow dot on active item */
.sb-item.on::after {
  content: '';
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--c-accent); opacity: 0.6;
}
.sb-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

.sb-user {
  padding: 12px 14px;
  border-top: 1px solid var(--c-border);
  background: var(--c-card);
}
.sb-user-info {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  background: var(--c-surface);
  border-radius: var(--r-sm);
  margin-bottom: 9px;
  border: 1px solid var(--c-border);
  transition: box-shadow var(--dur);
}
.sb-user-info:hover { box-shadow: var(--sh-xs); }
.sb-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--c-brand-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white; flex-shrink: 0;
}
.sb-uname { font-size: 13px; font-weight: 600; color: var(--c-text); line-height: 1.3; }
.sb-urole { font-size: 10px; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.7px; }

/* Topbar */
.topbar {
  position: fixed; left: var(--sidebar-w); right: 0; top: 0;
  height: var(--topbar-h);
  background: rgba(253, 252, 250, 0.85);
  backdrop-filter: blur(20px) saturate(200%);
  -webkit-backdrop-filter: blur(20px) saturate(200%);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px;
  z-index: 100;
}
[data-theme="dark"] .topbar { background: rgba(17, 21, 8, 0.85); }
.topbar-title {
  font-family: var(--f-display);
  font-size: 18px; letter-spacing: -0.3px;
  color: var(--c-text); font-weight: 400; font-style: italic;
}
.topbar-right { display: flex; gap: 7px; align-items: center; flex: 1; justify-content: flex-end; }

/* Stats ribbon */
#stats-ribbon {
  position: fixed; left: var(--sidebar-w); right: 0;
  top: var(--topbar-h); height: 34px;
  background: var(--c-accent);
  z-index: 85; display: none;
  align-items: center; overflow: hidden;
}
.ribbon-inner {
  display: flex; gap: 0; white-space: nowrap;
  animation: ribbonScroll 20s linear infinite;
}
.ribbon-item {
  padding: 0 28px; font-size: 11.5px; font-weight: 600;
  color: rgba(255,255,255,0.92); cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  height: 34px; border-right: 1px solid rgba(255,255,255,0.12);
  transition: background var(--dur);
}
.ribbon-item:hover { background: rgba(255,255,255,0.10); }
.ribbon-sep { padding: 0 12px; color: rgba(255,255,255,0.30); }

/* Main */
.main {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 32px;
  min-height: calc(100vh - var(--topbar-h));
}

/* Theme button */
.theme-toggle {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--c-card); border: 1.5px solid var(--c-border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--dur); flex-shrink: 0; color: var(--c-muted);
  font-size: 15px;
}
.theme-toggle:hover { background: var(--c-accent-subtle); border-color: var(--c-accent); }

/* ── VIEWS ── */
.view { display: none; animation: fadeUp 0.22s var(--ease-out); }
.view.on { display: block; }

/* Page header */
.ph {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 26px; flex-wrap: wrap; gap: 10px;
}
.ph-title {
  font-family: var(--f-display);
  font-size: 26px; font-weight: 400;
  letter-spacing: -0.5px; color: var(--c-text);
  font-style: italic;
}
.ph-sub { font-size: 13px; color: var(--c-muted); margin-top: 2px; }

/* Grid */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* Cards */
.s-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 22px;
  transition: box-shadow var(--dur), border-color var(--dur);
}
.s-card:hover { box-shadow: var(--sh-sm); }
.s-ct {
  font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--c-muted);
  margin-bottom: 16px;
}

/* KPIs */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.kpi {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 18px 20px;
  border-left: 3px solid var(--kc, var(--c-accent));
  transition: box-shadow var(--dur), transform var(--dur);
  cursor: default;
}
.kpi:hover { box-shadow: var(--sh-sm); transform: translateY(-1px); }
.kpi-lbl {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--c-muted);
  font-weight: 700; margin-bottom: 7px;
}
.kpi-val {
  font-family: var(--f-display);
  font-size: 28px; font-weight: 400;
  color: var(--c-text); letter-spacing: -0.5px;
}
.kpi-sub { font-size: 11px; color: var(--c-muted); margin-top: 3px; }

/* Sep */
.sep { height: 1px; background: var(--c-border); margin: 16px 0; }

/* Filter bar */
.fbar {
  display: flex; gap: 9px; margin-bottom: 14px;
  flex-wrap: wrap; align-items: center;
}

/* Status legend */
.status-legend {
  display: flex; gap: 7px; flex-wrap: wrap;
  align-items: center; margin-bottom: 14px;
  padding: 9px 14px;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md); font-size: 12px;
}
.status-legend-lbl { font-weight: 700; color: var(--c-muted); margin-right: 3px; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.1px; white-space: nowrap;
}
.b-new      { background: var(--c-accent-subtle);    color: var(--c-accent); }
.b-purchased{ background: var(--c-purple-bg);         color: var(--c-purple); }
.b-transit  { background: var(--c-info-bg);           color: var(--c-info); }
.b-received { background: var(--c-success-bg);        color: var(--c-success); }
.b-partial  { background: var(--c-warning-bg);        color: var(--c-warning); }
.b-invoiced { background: var(--c-card2); color: var(--c-text2); border: 1px solid var(--c-border2); }
.b-closed   { background: var(--c-bg); color: var(--c-muted); }
.b-green    { background: var(--c-success-bg);        color: var(--c-success); }
.b-red      { background: var(--c-danger-bg);         color: var(--c-danger); }
.b-yellow   { background: var(--c-warning-bg);        color: var(--c-warning); }
.b-blue     { background: var(--c-info-bg);           color: var(--c-info); }
.b-purple   { background: var(--c-purple-bg);         color: var(--c-purple); }
.b-gray     { background: var(--c-bg);                color: var(--c-muted); }
.b-flash    { background: var(--c-flash-bg);          color: var(--c-flash); border: 1px solid var(--c-flash-border); }

.tag {
  display: inline-flex; padding: 2px 8px;
  border-radius: 5px; font-size: 11px;
  background: var(--c-card); border: 1px solid var(--c-border);
  color: var(--c-text2);
}
.pp { color: var(--c-success); font-weight: 600; }
.pn { color: var(--c-danger);  font-weight: 600; }

/* ── TABLES ── */
.tw {
  overflow-x: auto; border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--c-card); }
th {
  padding: 10px 13px; text-align: left;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--c-muted); white-space: nowrap;
  border-bottom: 1px solid var(--c-border);
}
td {
  padding: 10px 13px; border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
tbody tr { transition: background var(--dur); }
tbody tr:hover { background: var(--c-accent-subtle); }
tbody tr:last-child td { border-bottom: none; }
tfoot { background: var(--c-card); font-size: 12px; font-weight: 600; border-top: 2px solid var(--c-border2); }

/* Row status colors */
.row-requested { border-left: 3px solid var(--c-accent); }
.row-purchased { border-left: 3px solid var(--c-purple); }
.row-received  { border-left: 3px solid var(--c-success); }
.row-partial   { border-left: 3px solid var(--c-warning); }
.row-invoiced  { border-left: 3px solid var(--c-muted2); }
.row-closed    { border-left: 3px solid var(--c-border2); }

/* Column toggle */
.col-precio,.col-ganancia,.col-proveedor,.col-facturas,.col-tracking { transition: opacity var(--dur); }
.col-precio.hidden,.col-ganancia.hidden,.col-proveedor.hidden,.col-facturas.hidden,.col-tracking.hidden { display: none; }

.col-toggle-menu {
  position: absolute; top: 100%; right: 0;
  background: var(--c-surface); border: 1.5px solid var(--c-border2);
  border-radius: var(--r-md); padding: 8px; z-index: 200;
  min-width: 210px; box-shadow: var(--sh-lg); display: none;
}
.col-toggle-menu.open { display: block; }
.col-toggle-item {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 12px; transition: background var(--dur);
}
.col-toggle-item:hover { background: var(--c-accent-subtle); }
.col-toggle-item input { accent-color: var(--c-accent); }

/* ── MODALES ── */
.modal-bg {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(26, 23, 18, 0.28);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.modal-bg.on { display: flex; }
.modal-box {
  position: relative; background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-xl);
  box-shadow: var(--sh-xl); width: 100%; max-width: 560px;
  max-height: 90vh; display: flex; flex-direction: column;
  animation: scaleIn 0.22s var(--ease-spring);
}
.modal-box.sm { max-width: 500px; }
.modal-box.lg { max-width: 820px; }

.m-head {
  padding: 20px 24px; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.m-title {
  font-family: var(--f-display);
  font-size: 18px; font-weight: 400; font-style: italic; letter-spacing: -0.3px;
}
.m-close {
  background: none; border: none; color: var(--c-muted);
  cursor: pointer; padding: 5px; border-radius: var(--r-sm);
  font-size: 18px; line-height: 1; transition: all var(--dur);
}
.m-close:hover { background: var(--c-card); color: var(--c-text); }
.m-body { padding: 24px; overflow-y: auto; flex: 1; }
.m-foot {
  padding: 14px 24px; border-top: 1px solid var(--c-border);
  display: flex; gap: 9px; justify-content: flex-end; flex-shrink: 0;
}

/* ── TOAST ── */
#toast-root {
  position: fixed; bottom: 22px; right: 22px; z-index: 9999;
  display: flex; flex-direction: column-reverse; gap: 7px;
  pointer-events: none;
}
.toast {
  pointer-events: auto; padding: 11px 16px;
  border-radius: var(--r-md); font-size: 13px; font-weight: 500;
  box-shadow: var(--sh-lg); animation: toastSlide 0.28s var(--ease-spring);
  display: flex; align-items: center; gap: 7px; max-width: 340px;
}
.ts { background: var(--c-success-bg); color: var(--c-success); border: 1px solid var(--c-success-border); }
.te { background: var(--c-danger-bg);  color: var(--c-danger);  border: 1px solid var(--c-danger-border); }
.toast.tw { background: var(--c-warning-bg); color: var(--c-warning); border: 1px solid var(--c-warning-border); }

/* ── EMPTY STATE ── */
.empty-box { text-align: center; padding: 52px 24px; }
.eb-icon  { font-size: 44px; margin-bottom: 12px; opacity: 0.6; }
.eb-title { font-family: var(--f-display); font-size: 16px; font-style: italic; color: var(--c-text2); }
.eb-sub   { font-size: 13px; color: var(--c-muted); margin-top: 4px; }

/* ── CHARTS ── */
.chart-wrap { position: relative; height: 210px; }
.bar-row { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 12px; }
.bar-lbl { width: 115px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--c-text2); }
.bar-track { flex: 1; height: 5px; background: var(--c-border); border-radius: 3px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 3px; transition: width 0.5s var(--ease-out); }
.bar-val   { width: 65px; text-align: right; font-weight: 600; color: var(--c-text); font-size: 11px; }

/* ── AUTOCOMPLETE ── */
.ac-wrap { position: relative; }
.ac-drop {
  position: fixed; z-index: 9000; background: var(--c-surface);
  border: 1.5px solid var(--c-border2); border-radius: var(--r-md);
  box-shadow: var(--sh-lg); max-height: 280px; overflow-y: auto; display: none;
}
.ac-item {
  padding: 9px 13px; cursor: pointer; transition: background var(--dur);
  border-bottom: 1px solid var(--c-border);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: var(--c-accent-subtle); }
.ac-sku  { font-family: var(--f-mono); font-size: 12px; font-weight: 600; color: var(--c-accent); }
.ac-desc { display: block; font-size: 12px; color: var(--c-text2); margin-top: 2px; }
.ac-sub  { display: block; font-size: 11px; color: var(--c-muted); margin-top: 1px; }
.ac-new  { color: var(--c-accent); font-weight: 600; font-size: 12px; }

/* ── INVOICE ── */
.inv-line-row {
  display: flex; gap: 10px; align-items: center; padding: 11px;
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--r-md); transition: border-color var(--dur);
}
.inv-line-row:hover { border-color: var(--c-accent); }
.inv-line-info  { flex: 1; min-width: 0; }
.inv-line-sku   { font-family: var(--f-mono); font-size: 12px; font-weight: 600; color: var(--c-accent); }
.inv-line-desc  { font-size: 12px; color: var(--c-text2); margin-top: 2px; }
.inv-line-avail { font-size: 11px; color: var(--c-muted); margin-top: 3px; }
.inv-qty-input  { width: 62px; text-align: center; }
.inv-acc { padding: 13px; background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--r-md); }
.inv-acc-bar { height: 4px; background: var(--c-border); border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.inv-acc-fill { height: 100%; border-radius: 3px; transition: width 0.3s, background 0.3s; background: var(--c-accent); }
.inv-acc-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--c-muted); }

/* ── PRICE ROW ── */
.price-row {
  display: flex; gap: 10px; justify-content: center; align-items: center;
  padding: 13px; background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}
.price-item { text-align: center; flex: 1; }
.price-lbl  { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--c-muted); margin-bottom: 3px; }
.price-val  { font-family: var(--f-display); font-size: 19px; font-weight: 400; color: var(--c-text); }

/* ── ADJUNTOS ── */
.attach-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.attach-item {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px;
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--r-sm); font-size: 12px;
}
.attach-icon { font-size: 13px; }
.attach-name { color: var(--c-text2); max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { color: var(--c-muted2); font-size: 10px; }
.attach-del  { background: none; border: none; color: var(--c-danger); cursor: pointer; font-size: 13px; padding: 0 2px; line-height: 1; }
.attach-zone {
  border: 1.5px dashed var(--c-border2); border-radius: var(--r-md);
  padding: 22px; text-align: center; cursor: pointer; transition: all var(--dur);
}
.attach-zone:hover, .attach-zone.drag { border-color: var(--c-accent); background: var(--c-accent-subtle); }

/* ── LOG ── */
.log-entry { display: flex; gap: 9px; padding: 7px 0; border-bottom: 1px solid var(--c-border); }
.log-dot   { width: 7px; height: 7px; border-radius: 50%; background: var(--c-muted2); flex-shrink: 0; margin-top: 5px; }
.log-dot.status  { background: var(--c-accent); }
.log-dot.invoice { background: var(--c-warning); }
.log-dot.note    { background: var(--c-purple); }
.log-text  { flex: 1; font-size: 13px; }
.log-time  { font-size: 11px; color: var(--c-muted); }

/* ── AI CHAT ── */
#ai-fab {
  position: fixed; bottom: 22px; right: 22px; z-index: 800;
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--c-brand-gradient); border: none; cursor: pointer;
  box-shadow: var(--sh-accent);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 20px;
  transition: transform var(--dur), box-shadow var(--dur);
}
#ai-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(30,92,56,0.42); }
#ai-fab.open  { transform: scale(1.05); }
.ai-pulse {
  position: absolute; inset: -3px; border-radius: 50%;
  border: 2px solid var(--c-accent); opacity: 0;
  animation: aipulse 2.5s infinite;
}
#ai-panel {
  position: fixed; bottom: 84px; right: 22px; z-index: 800;
  width: 390px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-xl); box-shadow: var(--sh-xl);
  display: flex; flex-direction: column;
  transform: scale(0.94) translateY(14px); opacity: 0; pointer-events: none;
  transition: transform 0.22s var(--ease-out), opacity 0.22s var(--ease-out);
  overflow: hidden;
}
#ai-panel.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }
.ai-header {
  padding: 13px 16px; border-bottom: 1px solid var(--c-border);
  background: var(--c-card); display: flex; align-items: center; gap: 9px; flex-shrink: 0;
}
.ai-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--c-brand-gradient);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 13px; flex-shrink: 0;
}
.ai-header-name { font-size: 14px; font-weight: 600; }
.ai-header-sub  { font-size: 11px; color: var(--c-muted); }
.ai-close {
  margin-left: auto; background: none; border: none; color: var(--c-muted);
  cursor: pointer; padding: 4px; border-radius: var(--r-sm); font-size: 16px;
  transition: all var(--dur);
}
.ai-close:hover { background: var(--c-border); color: var(--c-text); }
.ai-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 9px; min-height: 180px; }
.ai-msg { display: flex; gap: 7px; align-items: flex-start; animation: fadeUp 0.18s var(--ease-out); }
.ai-msg.user { flex-direction: row-reverse; }
.ai-msg-avatar {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.ai-msg.assistant .ai-msg-avatar { background: var(--c-brand-gradient); color: white; }
.ai-msg.user .ai-msg-avatar { background: var(--c-border); color: var(--c-muted); font-size: 10px; font-weight: 700; }
.ai-bubble {
  max-width: 82%; padding: 9px 12px; border-radius: var(--r-md);
  font-size: 13px; line-height: 1.55; word-wrap: break-word;
}
.ai-msg.assistant .ai-bubble { background: var(--c-card); border: 1px solid var(--c-border); color: var(--c-text); border-bottom-left-radius: 4px; }
.ai-msg.user .ai-bubble { background: var(--c-accent); color: white; border-bottom-right-radius: 4px; }
.ai-bubble code { background: rgba(0,0,0,0.08); padding: 1px 4px; border-radius: 4px; font-family: var(--f-mono); font-size: 12px; }
.ai-typing { display: flex; gap: 4px; padding: 3px 0; align-items: center; }
.ai-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c-muted); animation: aidot 1.2s infinite; }
.ai-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-dot:nth-child(3) { animation-delay: 0.4s; }
.ai-suggestions { padding: 7px 12px; display: flex; gap: 5px; flex-wrap: wrap; flex-shrink: 0; border-top: 1px solid var(--c-border); background: var(--c-card); }
.ai-chip {
  font-family: var(--f-body); font-size: 11px; padding: 4px 9px;
  border-radius: var(--r-pill); background: var(--c-surface);
  border: 1.5px solid var(--c-border); cursor: pointer; color: var(--c-muted);
  transition: all var(--dur); white-space: nowrap;
}
.ai-chip:hover { border-color: var(--c-accent); color: var(--c-accent); background: var(--c-accent-subtle); }
.ai-input-row { padding: 10px 12px; border-top: 1px solid var(--c-border); display: flex; gap: 7px; align-items: flex-end; flex-shrink: 0; }
#ai-input {
  flex: 1; font-family: var(--f-body); font-size: 13px; background: var(--c-card);
  border: 1.5px solid var(--c-border); color: var(--c-text);
  padding: 8px 11px; border-radius: var(--r-md); outline: none;
  resize: none; max-height: 100px; min-height: 36px; transition: border-color var(--dur);
}
#ai-input:focus { border-color: var(--c-accent); }
#ai-input::placeholder { color: var(--c-ph); }
#ai-send {
  width: 34px; height: 34px; border-radius: var(--r-md); flex-shrink: 0;
  background: var(--c-brand-gradient); border: none; color: white;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--dur);
}
#ai-send:hover { filter: brightness(1.1); transform: translateY(-1px); }
#ai-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── GLOBAL SEARCH ── */
#global-search {
  font-family: var(--f-body); font-size: 12px;
  background: var(--c-card); border: 1.5px solid var(--c-border);
  color: var(--c-text); padding: 7px 30px 7px 11px;
  border-radius: var(--r-sm); outline: none;
  width: 190px; transition: all 0.22s;
}
#global-search:focus { width: 250px; border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-subtle); }
#global-search::placeholder { color: var(--c-ph); }
#global-search-results {
  position: absolute; top: calc(100% + 4px); right: 0;
  width: 330px; background: var(--c-surface);
  border: 1.5px solid var(--c-border2);
  border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  z-index: 500; max-height: 340px; overflow-y: auto;
}

/* ── QUOTER TABS (módulos del cotizador) ── */
.quoter-tabs {
  display: flex; gap: 0; margin-bottom: 24px;
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: 5px; overflow-x: auto;
}
.quoter-tab {
  flex: 1; min-width: 120px; padding: 11px 16px;
  text-align: center; cursor: pointer; font-size: 13px; font-weight: 600;
  border-radius: var(--r-md); color: var(--c-muted);
  transition: all var(--dur2) var(--ease-out);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
.quoter-tab:hover { color: var(--c-text2); background: var(--c-card2); }
.quoter-tab.on {
  background: var(--c-accent);
  color: white;
  box-shadow: var(--sh-accent);
}
.quoter-panel { display: none; animation: fadeUp 0.2s var(--ease-out); }
.quoter-panel.on { display: block; }

/* ── COMPRAS VENDEDORES ── */
.cv-request-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); overflow: hidden;
  transition: box-shadow var(--dur), border-color var(--dur);
}
.cv-request-card:hover { box-shadow: var(--sh-sm); border-color: var(--c-border2); }
.cv-request-header {
  padding: 14px 18px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--c-card); border-bottom: 1px solid var(--c-border);
}
.cv-request-body { padding: 0; }
.cv-status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600;
}
.cv-status-draft    { background: var(--c-card2); color: var(--c-muted); }
.cv-status-pending  { background: var(--c-warning-bg); color: var(--c-warning); }
.cv-status-approved { background: var(--c-success-bg); color: var(--c-success); }
.cv-status-rejected { background: var(--c-danger-bg); color: var(--c-danger); }

/* ── ADMIN PARAM ── */
.admin-param:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── TRACKING ── */
#tracking-screen {
  min-height: 100vh; background: var(--c-bg);
  display: flex; flex-direction: column; align-items: center; padding: 24px;
}

/* ── PRINT ── */
@media print {
  nav.sidebar, .topbar, #ai-fab, #ai-panel, #stats-ribbon, #toast-root { display: none !important; }
  .main { margin: 0; padding: 20px; }
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) { .g2 { grid-template-columns: 1fr; } .fg2 { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  nav.sidebar { transform: translateX(-100%); }
  nav.sidebar.open { transform: translateX(0); }
  .topbar { left: 0; }
  .main { margin-left: 0; margin-top: var(--topbar-h); padding: 14px; }
  #stats-ribbon { left: 0; }
}

/* ════════════════════════════════════
   LEGACY VARIABLE MAPPING
   (todos los .js usan var(--accent), etc.)
   ════════════════════════════════════ */
:root {
  --bg:            var(--c-bg);
  --surface:       var(--c-surface);
  --card:          var(--c-card);
  --border:        var(--c-border);
  --border2:       var(--c-border2);
  --text:          var(--c-text);
  --muted:         var(--c-muted);
  --muted2:        var(--c-muted2);
  --accent:        var(--c-accent);
  --accent-dark:   var(--c-accent-hover);
  --accent-light:  var(--c-accent-subtle);
  --accent-glow:   var(--c-accent-glow);
  --green:         var(--c-success);
  --green-bg:      var(--c-success-bg);
  --green-border:  var(--c-success-border);
  --yellow:        var(--c-warning);
  --yellow-bg:     var(--c-warning-bg);
  --yellow-border: var(--c-warning-border);
  --red:           var(--c-danger);
  --red-bg:        var(--c-danger-bg);
  --red-border:    var(--c-danger-border);
  --cyan:          var(--c-info);
  --cyan-bg:       var(--c-info-bg);
  --cyan-border:   var(--c-info-border);
  --purple:        var(--c-purple);
  --purple-bg:     var(--c-purple-bg);
  --purple-border: var(--c-purple-border);
  --orange:        var(--c-orange);
  --orange-bg:     var(--c-orange-bg);
  --orange-border: var(--c-orange-border);
  --shadow:        var(--sh-md);
  --shadow-lg:     var(--sh-lg);
  --shadow-sm:     var(--sh-sm);
  --sidebar-w:     260px;
  --top-h:         58px;
  --topbar-h:      58px;
}
[data-theme="dark"] tbody tr:hover { background: rgba(66,192,120,0.06) !important; }
[data-theme="dark"] .ac-item:hover { background: rgba(66,192,120,0.09); }
