/* ════════════════════════════════════════
   FDR ERP · main.css  — Minimal Light
════════════════════════════════════════ */

/* ─── VARIABLES ─── */
:root {
  /* ── Colores exactos del logo FDR ── */
  --fdr-red:       #e31e24;
  --fdr-red2:      #b8161b;
  --fdr-red-light: #fff0f0;
  --fdr-red-mid:   #fddcdc;
  --fdr-navy:      #1a3fa0;
  --fdr-navy2:     #0e2670;
  --fdr-navy-light:#eef2fc;

  --bg:         #f2f4f8;
  --surface:    #ffffff;
  --surface2:   #f7f9fc;
  --border:     #e2e6ef;
  --border2:    #edf0f6;
  --text:       #111827;
  --muted:      #6b7280;
  --muted2:     #c4c9d4;

  --danger:     #e03030;
  --success:    #1a9e4a;
  --warn:       #c97c10;

  --shadow-sm:  0 1px 4px rgba(26,63,160,.08);
  --shadow-md:  0 4px 16px rgba(26,63,160,.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.12);

  /* Legacy vars kept for compatibility */
  --glass:        #ffffff;
  --glass-border: #e2e6ef;
  --fdr-blue:     #1a3fa0;
  --fdr-light:    #1a3fa0;
  --light:        #1a3fa0;
}

/* ─── EASINGS ─── */
:root {
  --ease-out-quint:   cubic-bezier(.23, 1, .32, 1);
  --ease-in-out:      cubic-bezier(.645, .045, .355, 1);
  --ease-out-cubic:   cubic-bezier(.33, 1, .68, 1);
  --ease-spring:      cubic-bezier(.34, 1.56, .64, 1);
}

/* ─── RESET ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Montserrat', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(26,58,143,.04) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(210,2,17,.03) 0%, transparent 50%);
}

/* ─── TOAST ─── */
#toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999; display: flex; flex-direction: column; gap: .5rem;
}
.toast-item {
  padding: .8rem 1.2rem; border-radius: 10px;
  font-size: .83rem; font-weight: 600;
  animation: toastIn .25s ease;
  box-shadow: var(--shadow-lg);
  max-width: 320px;
}
.toast-ok   { background: #fff; border-left: 3px solid var(--success); color: var(--success); }
.toast-err  { background: #fff; border-left: 3px solid var(--danger);  color: var(--danger);  }
.toast-info { background: #fff; border-left: 3px solid var(--fdr-red); color: var(--fdr-red); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0);    }
}

/* ─── LOGIN ─── */
#login-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  background: var(--bg);
}
.login-wrap {
  display: grid; grid-template-columns: 1fr 1fr;
  width: 100%; max-width: 860px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
@media (max-width: 640px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-left { display: none !important; }
}
.login-left {
  background: linear-gradient(145deg, var(--fdr-navy), var(--fdr-navy2));
  padding: 3rem;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-brand   { display: flex; align-items: center; gap: .8rem; }
.brand-box     { width: 44px; height: 44px; background: rgba(255,255,255,.15); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.brand-name    { font-family: 'Montserrat', sans-serif; font-size: 1.5rem; font-weight: 900; letter-spacing: 1px; color: white; }
.brand-sub     { font-size: .68rem; color: rgba(255,255,255,.65); letter-spacing: 2px; text-transform: uppercase; }
.login-tagline { font-size: 2rem; font-weight: 800; line-height: 1.25; color: white; }
.login-tagline span { color: rgba(255,255,255,.65); }
.login-stats   { display: flex; gap: 1.5rem; }
.lst           { text-align: center; }
.lst-n         { font-size: 1.7rem; font-weight: 900; color: white; }
.lst-l         { font-size: .65rem; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: 1px; }
.login-right   { padding: 2.5rem; }
.login-title   { font-size: 1.6rem; font-weight: 800; margin-bottom: .3rem; color: var(--text); }
.login-sub     { font-size: .82rem; color: var(--muted); margin-bottom: 2rem; }

.form-label {
  font-size: .72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: .35rem; display: block;
}
.form-input {
  width: 100%; padding: .72rem 1rem;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: 'Montserrat', sans-serif; font-size: .88rem;
  outline: none; transition: border .18s; margin-bottom: 1rem;
  -webkit-appearance: none; appearance: none;
}
.form-input:focus { border-color: var(--fdr-red); background: #fff; }
.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus,
.form-input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--surface2) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  border-color: var(--border) !important;
  transition: background-color 9999s ease-in-out 0s;
}

.roles-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1.2rem; }
.role-btn {
  padding: .55rem; background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 8px; color: var(--muted);
  font-family: 'Montserrat', sans-serif; font-size: .76rem; font-weight: 600;
  cursor: pointer; transition: all .18s; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: .4rem;
}
.role-btn:hover    { border-color: var(--fdr-red); color: var(--text); }
.role-btn.selected { border-color: var(--fdr-red); background: var(--fdr-red-light); color: var(--fdr-red); }

.btn-login {
  width: 100%; padding: .85rem;
  background: var(--fdr-red); border: none; border-radius: 8px;
  color: white; font-family: 'Montserrat', sans-serif;
  font-size: 1rem; font-weight: 700; letter-spacing: .5px;
  cursor: pointer; transition: all .18s; margin-top: .5rem;
}
.btn-login:hover    { background: var(--fdr-red2); box-shadow: 0 4px 16px rgba(210,2,17,.3); }
.btn-login:disabled { opacity: .6; cursor: not-allowed; }

.err-msg {
  background: var(--fdr-red-light); border: 1px solid rgba(210,2,17,.2);
  border-radius: 8px; padding: .65rem 1rem; font-size: .82rem;
  color: var(--fdr-red); margin-bottom: 1rem; display: none;
}
.users-hint {
  margin-top: 1.5rem; padding: .9rem; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: .73rem; color: var(--muted); line-height: 1.7;
}
.users-hint strong { color: var(--text); display: block; margin-bottom: .3rem; }

/* ─── APP LAYOUT ─── */
#app-screen { display: none; min-height: 100vh; position: relative; overflow-x: hidden; }
#app-screen::before, #app-screen::after { display: none; }

/* ─── PAGE TRANSITIONS ─── */
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: scale(1); }
}

.page-content { animation: pageIn .3s var(--ease-out-quint) both; }

/* KPI cards con stagger */
.kpi-card {
  animation: slideUp .35s var(--ease-out-quint) both;
}
.kpi-card:nth-child(1) { animation-delay: .04s; }
.kpi-card:nth-child(2) { animation-delay: .08s; }
.kpi-card:nth-child(3) { animation-delay: .12s; }
.kpi-card:nth-child(4) { animation-delay: .16s; }

/* Section cards */
.section-card { animation: fadeIn .3s var(--ease-out-cubic) both; }

/* Filas de tabla */
tbody tr {
  animation: slideUp .25s var(--ease-out-cubic) both;
}
/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .page-content, .kpi-card, .section-card, tbody tr {
    animation: none !important;
  }
}

/* ══════════════════════════════════
   SIDEBAR
══════════════════════════════════ */
.sidebar {
  width: 240px; min-width: 240px;
  background: var(--fdr-navy2);
  border-right: none;
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0;
  height: 100vh; height: 100dvh;
  z-index: 200; transition: transform .3s ease;
  box-shadow: 4px 0 20px rgba(14,38,112,.25);
  overflow-x: hidden; overflow-y: hidden;
}
@media (min-width: 769px) and (max-width: 1023px) {
  .sidebar { width: 200px; min-width: 200px; }
  .sidebar-header { padding: .8rem; }
  .sb-logo-img { max-width: 120px; height: 42px; }
  .main-content { margin-left: 200px !important; }
  .topbar { left: 200px !important; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .topbar { left: 0 !important; }
  .sidebar-header { padding: .6rem .8rem .5rem; }
  .sb-logo-img { height: 38px; }
  .sb-brand { font-size: .52rem; }
  .role-badge { margin: .4rem .8rem; padding: .35rem .7rem; }
}

.sidebar-header {
  padding: 1.2rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; flex-direction: column;
  align-items: center; gap: .3rem;
  flex-shrink: 0; overflow: hidden;
  background: rgba(255,255,255,.06);
}
.sb-logo-img {
  height: 54px; width: auto; max-width: 140px;
  object-fit: contain; display: block;
  filter: none;
}
.sb-brand {
  font-size: .54rem; font-weight: 700;
  letter-spacing: .2em; text-transform: uppercase;
  color: rgba(255,255,255,.45); text-align: center; white-space: nowrap;
}
.sb-logo-box { display: none; }

.role-badge {
  margin: .8rem 1rem;
  padding: .4rem .8rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px;
  display: flex; align-items: center; gap: .55rem; font-size: .73rem;
}
#s-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
#s-role-label { color: rgba(255,255,255,.85); font-weight: 700; letter-spacing: .04em; }

.nav-section {
  padding: .9rem 1.2rem .3rem;
  font-size: .54rem; font-weight: 800;
  color: rgba(255,255,255,.35);
  letter-spacing: .2em; text-transform: uppercase;
}

.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .58rem 1rem; margin: 1px .6rem;
  border-radius: 7px; cursor: pointer;
  font-size: .8rem; font-weight: 500; color: rgba(255,255,255,.6);
  transition: background 180ms var(--ease-out-cubic),
              color      180ms var(--ease-out-cubic),
              transform  150ms var(--ease-out-cubic);
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
  transform: translateX(2px);
}
.nav-item:active { transform: scale(.97); }
.nav-item.active {
  background: var(--fdr-red);
  color: #fff; font-weight: 700;
  box-shadow: 0 2px 12px rgba(227,30,36,.4);
}
.nav-item.active::before { display: none; }
.ni-svg { flex-shrink: 0; stroke: currentColor; }

/* Nav scroll */
.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.sidebar-footer {
  flex-shrink: 0;
  padding: 1rem 1.2rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.15);
}
.user-info { display: flex; align-items: center; gap: .7rem; margin-bottom: .8rem; }
.user-avatar {
  width: 34px; height: 34px;
  background: var(--fdr-red);
  border: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-weight: 800; font-size: .8rem; color: #fff;
}
.user-name { font-size: .82rem; font-weight: 700; color: rgba(255,255,255,.9); }
.user-role { font-size: .63rem; color: rgba(255,255,255,.45); letter-spacing: .05em; text-transform: uppercase; }
.btn-logout {
  width: 100%; padding: .5rem;
  background: transparent; border: 1px solid rgba(255,255,255,.15);
  border-radius: 7px; color: rgba(255,255,255,.5);
  font-family: 'Montserrat', sans-serif; font-size: .74rem;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: .5rem; transition: all .18s;
  letter-spacing: .06em;
}
.btn-logout:hover { border-color: var(--fdr-red); color: #fff; background: var(--fdr-red); }

/* ══════════════════════════════════
   OVERLAY MÓVIL
══════════════════════════════════ */
#sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(2px);
  z-index: 199; -webkit-tap-highlight-color: transparent; touch-action: none;
}

/* ══════════════════════════════════
   TOPBAR
══════════════════════════════════ */
.topbar {
  position: fixed; top: 0; left: 240px; right: 0; height: 52px;
  background: var(--surface);
  border-bottom: 2px solid var(--fdr-navy);
  display: flex; align-items: center; padding: 0 1.2rem;
  gap: .7rem; z-index: 100; transition: left .3s;
  box-shadow: 0 2px 12px rgba(26,63,160,.08);
  min-width: 0; overflow: hidden;
}
@media (max-width: 768px) { .topbar { left: 0 !important; padding: 0 .8rem; } }
.topbar-hamburger {
  display: none; background: none; border: none;
  color: var(--text); cursor: pointer; padding: .3rem; flex-shrink: 0;
}
@media (max-width: 768px) { .topbar-hamburger { display: flex; } }
.topbar-title {
  font-size: .85rem; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase;
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.topbar-badge {
  background: var(--fdr-red-light);
  border: 1px solid rgba(210,2,17,.2);
  border-radius: 6px; padding: .2rem .55rem;
  font-size: .62rem; font-weight: 700;
  color: var(--fdr-red); letter-spacing: .06em;
  text-transform: uppercase; white-space: nowrap; flex-shrink: 0;
}
.topbar-date {
  font-size: .7rem; color: var(--muted);
  white-space: nowrap; flex-shrink: 0;
}
@media (max-width: 400px) { .topbar-date { display: none; } }

/* ══════════════════════════════════
   MAIN CONTENT
══════════════════════════════════ */
.main-content {
  margin-left: 240px; padding-top: 52px;
  min-height: 100vh; transition: margin .3s;
  overflow-x: hidden;
}
.page-content { padding: 1.4rem; }
@media (max-width: 768px) {
  .main-content { margin-left: 0; }
  .page-content { padding: .9rem; }
}

/* ─── KPI CARDS ─── */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 1023px) { .kpi-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 480px)  { .kpi-grid { grid-template-columns: 1fr 1fr; gap: .6rem; } }
@media (max-width: 640px) {
  .kpi-grid[style*="repeat(3"] { grid-template-columns: 1fr !important; }
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 1.1rem;
  position: relative; overflow: hidden;
  transition: border-color 200ms var(--ease-out-quint),
              box-shadow  200ms var(--ease-out-quint),
              transform   200ms var(--ease-out-quint);
}
.kpi-card:hover {
  border-color: rgba(26,58,143,.2);
  box-shadow: 0 8px 24px rgba(26,58,143,.10);
  transform: translateY(-3px);
}
.kpi-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, var(--fdr-red), var(--fdr-navy));
  opacity: 0; transition: opacity .2s;
}
.kpi-card:hover::before { opacity: 1; }
.kpi-card:nth-child(1) { border-top: 3px solid var(--fdr-red);   }
.kpi-card:nth-child(2) { border-top: 3px solid var(--fdr-navy);  }
.kpi-card:nth-child(3) { border-top: 3px solid var(--success);   }
.kpi-card:nth-child(4) { border-top: 3px solid var(--warn);      }
.kpi-card:nth-child(1) .kpi-value { color: var(--fdr-red);   }
.kpi-card:nth-child(2) .kpi-value { color: var(--fdr-navy);  }
.kpi-card:nth-child(3) .kpi-value { color: var(--success);   }
.kpi-card:nth-child(4) .kpi-value { color: var(--warn);      }
.kpi-label {
  font-size: .6rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: .5rem; line-height: 1.3;
}
.kpi-value {
  font-size: 1.7rem; font-weight: 800;
  line-height: 1; letter-spacing: -.02em;
  word-break: break-all; color: var(--text);
}
@media (max-width: 480px) {
  .kpi-card { padding: .8rem; border-radius: 10px; }
  .kpi-value { font-size: 1.3rem; }
  .kpi-label { font-size: .55rem; }
}
.kpi-sub  { font-size: .7rem; color: var(--muted); margin-top: .35rem; line-height: 1.3; }
.kpi-icon { position: absolute; right: .9rem; top: .9rem; opacity: .06; }

/* ─── SECTION CARDS ─── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 1rem;
}
.section-header {
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem;
  background: linear-gradient(to right, #fafbff, #fff);
}
.section-title {
  font-size: .72rem; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase;
  display: flex; align-items: center; gap: .5rem; color: var(--text);
}

/* ─── BOTONES ─── */
.btn-sm {
  padding: .42rem .9rem; border-radius: 7px;
  font-family: 'Montserrat', sans-serif; font-size: .72rem; font-weight: 700;
  cursor: pointer; border: none;
  display: inline-flex; align-items: center; gap: .4rem;
  transition: transform 100ms var(--ease-out-cubic),
              box-shadow 150ms var(--ease-out-quint),
              background 150ms ease,
              border-color 150ms ease;
  letter-spacing: .04em;
}
.btn-sm:active { transform: scale(.96); }
.btn-primary {
  background: var(--fdr-red); color: white;
  box-shadow: 0 2px 8px rgba(210,2,17,.25);
}
.btn-primary:hover {
  background: var(--fdr-red2);
  box-shadow: 0 5px 16px rgba(210,2,17,.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: scale(.96); box-shadow: 0 2px 6px rgba(210,2,17,.2); }
.btn-danger  { background: #fff5f5; color: var(--danger); border: 1px solid rgba(224,48,48,.2); }
.btn-danger:hover { background: #ffe8e8; }
.btn-success { background: #f0faf3; color: var(--success); border: 1px solid rgba(26,158,74,.2); }
.btn-outline { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--fdr-red); color: var(--fdr-red); background: var(--fdr-red-light); }

/* ─── TABLA ─── */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.table-wrap::-webkit-scrollbar { height: 4px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th {
  padding: .6rem .9rem; text-align: left;
  font-size: .58rem; font-weight: 800; color: var(--fdr-navy);
  text-transform: uppercase; letter-spacing: .12em;
  border-bottom: 2px solid var(--border); white-space: nowrap;
  background: #f4f6fb;
}
td {
  padding: .65rem .9rem;
  border-bottom: 1px solid var(--border2);
  vertical-align: middle; font-size: .8rem; color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr { transition: background 150ms ease; }
tr:hover td { background: #f4f6fb; }

code {
  font-size: .72rem; background: var(--fdr-red-light);
  border: 1px solid rgba(210,2,17,.15);
  padding: .12rem .4rem; border-radius: 5px; color: var(--fdr-red);
  font-family: 'Courier New', monospace; white-space: nowrap;
}

@media (min-width: 769px) and (max-width: 1023px) {
  table { font-size: .88rem; }
  th { padding: .55rem .75rem; font-size: .60rem; }
  td { padding: .60rem .75rem; font-size: .85rem; }
}
@media (max-width: 640px) {
  th { padding: .5rem .6rem; font-size: .55rem; }
  td { padding: .55rem .6rem; font-size: .75rem; }
}

/* ─── BADGES ─── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 20px;
  font-size: .7rem; font-weight: 600;
}
.badge-ok         { background: #f0faf3;  color: var(--success); border: 1px solid rgba(26,158,74,.2);  }
.badge-bajo       { background: #fff8ec; color: var(--warn);    border: 1px solid rgba(201,124,16,.2); }
.badge-agotado    { background: #fff5f5;  color: var(--danger);  border: 1px solid rgba(224,48,48,.2);  }
.badge-pendiente  { background: #fff8ec; color: var(--warn);    }
.badge-enviado    { background: var(--fdr-red-light); color: var(--fdr-red); }
.badge-entregado  { background: #f0faf3;  color: var(--success); }
.badge-procesando { background: #f5f0ff; color: #7c4dff;        }

/* ─── STOCK BAR ─── */
.stock-bar-wrap  { display: flex; align-items: center; gap: .6rem; }
.stock-bar-bg    { flex: 1; height: 4px; background: var(--border); border-radius: 2px; min-width: 50px; }
.stock-bar-fill  { height: 4px; border-radius: 2px; transition: width .3s; }

/* ─── PRODUCT CELL ─── */
.product-cell { display: flex; align-items: center; gap: .7rem; }
.product-thumb {
  width: 32px; height: 32px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 7px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ─── FILTROS ─── */
.filters-bar {
  padding: .75rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
  background: var(--surface);
}
.filter-input {
  flex: 1; min-width: 140px; padding: .42rem .75rem;
  font-size: .8rem; background: var(--surface2);
  border: 1.5px solid var(--border); border-radius: 7px;
  color: var(--text); font-family: 'Montserrat', sans-serif;
  outline: none; transition: border .18s; -webkit-appearance: none;
}
.filter-input:focus { border-color: var(--fdr-red); background: #fff; }
.filter-select {
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 7px; padding: .42rem .75rem;
  color: var(--text); font-family: 'Montserrat', sans-serif;
  font-size: .78rem; outline: none; transition: border .18s;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center;
  padding-right: 1.8rem;
}
.filter-select:focus { border-color: var(--fdr-red); background-color: #fff; }
.filter-count {
  font-size: .7rem; color: var(--muted); white-space: nowrap;
  margin-left: auto; letter-spacing: .04em;
}
@media (min-width: 769px) and (max-width: 1023px) {
  .filters-bar { padding: .6rem .8rem; gap: .6rem; }
  .filter-input { flex: 1; min-width: 120px; font-size: .85rem; }
  .filter-select { font-size: .82rem; }
}
@media (max-width: 480px) {
  .filters-bar { padding: .6rem .7rem; }
  .filter-input { min-width: 100%; }
  .filter-select { flex: 1; min-width: calc(50% - .25rem); }
}

/* ─── MODAL ─── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 1000;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  animation: scaleIn .22s var(--ease-out-quint) both;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
@media (min-width: 769px) and (max-width: 1023px) { .modal { max-width: 640px; } }
@media (max-width: 640px) {
  .modal-overlay { align-items: flex-end; justify-content: stretch; padding: 0; }
  .modal { max-width: 100%; width: 100%; max-height: 95vh; border-radius: 20px 20px 0 0; border-bottom: none; }
}
.modal-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; position: sticky; top: 0;
  background: var(--surface); z-index: 2;
}
.modal-title  { font-size: 1rem; font-weight: 700; color: var(--text); }
.modal-close  {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; font-size: 1rem;
  padding: .3rem .6rem; border-radius: 6px; flex-shrink: 0;
  transition: all .15s;
}
.modal-close:hover { background: var(--fdr-red-light); color: var(--fdr-red); border-color: rgba(210,2,17,.2); }
.modal-body   { padding: 1.2rem; flex: 1; overflow-y: auto; }
.modal-footer {
  padding: .9rem 1.2rem; border-top: 1px solid var(--border);
  display: flex; gap: .6rem; justify-content: flex-end;
  flex-shrink: 0; flex-wrap: wrap;
  position: sticky; bottom: 0; background: var(--surface); z-index: 2;
}
@media (max-width: 640px) {
  .modal-footer { padding-bottom: calc(.9rem + env(safe-area-inset-bottom)); }
  .modal-footer .btn-sm { flex: 1; justify-content: center; padding: .7rem; }
}

/* FORM DENTRO DE MODAL */
.form-row { margin-bottom: .9rem; }
.form-row label {
  display: block; font-size: .7rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: .3rem;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%; padding: .62rem .9rem;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: 'Montserrat', sans-serif; font-size: .88rem;
  outline: none; transition: border .18s;
  -webkit-appearance: none; appearance: none;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus { border-color: var(--fdr-navy); background: #fff; }
.form-row textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ─── PEDIDO / COT: LINE ITEMS ─── */
.line-items {
  border: 1px solid var(--border); border-radius: 8px;
  overflow: visible; margin-bottom: 1rem;
}
.li-header {
  display: grid; grid-template-columns: minmax(0,1fr) 74px 78px 82px 30px;
  gap: .35rem; padding: .45rem .5rem;
  background: var(--surface2);
  font-size: .6rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
}
.li-row {
  display: grid; grid-template-columns: 3fr 1fr 1fr 1fr auto;
  gap: .5rem; padding: .5rem .9rem;
  border-top: 1px solid var(--border);
  align-items: center; font-size: .83rem;
}
@media (max-width: 640px) {
  .li-header { display: none; }
  .li-row {
    grid-template-columns: 1fr 1fr; gap: .5rem; padding: .9rem;
    background: var(--surface2); border-radius: 10px; margin: .5rem;
    border: 1px solid var(--border); border-top: 1px solid var(--border);
  }
  .li-row > div:first-child { grid-column: 1 / -1; }
  .li-row > div:last-child { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
  .li-row > *[data-label]::before {
    content: attr(data-label); display: block;
    font-size: .65rem; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .4px; margin-bottom: .2rem;
  }
}
.ped-line-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 74px 78px 82px 30px;
  gap: .35rem; align-items: center;
  padding: .45rem .5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: .4rem;
}
@media (max-width: 640px) {
  .li-header { display: none !important; }
  .ped-line-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto; gap: .4rem; padding: .7rem;
  }
  .ped-line-row > div:first-child { grid-column: 1 / -1; }
  .ped-line-row > div:nth-child(2) { justify-self: start; }
  .ped-line-row > div:nth-child(3) { justify-self: center; text-align: center; }
  .ped-line-row > div:nth-child(4) { justify-self: end; text-align: right; }
  .ped-line-row > div:nth-child(5) { justify-self: end; }
}
.totals-box {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: .9rem 1.2rem;
}
.total-row  { display: flex; justify-content: space-between; font-size: .85rem; padding: .25rem 0; color: var(--text); }
.total-row.final {
  font-size: 1.1rem; font-weight: 700; color: var(--fdr-red);
  padding-top: .5rem; border-top: 1px solid var(--border); margin-top: .3rem;
}

/* ─── REPORTES: BARRAS ─── */
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding: 1rem 1.4rem; }
.chart-bar-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.chart-bar  { width: 100%; background: var(--fdr-red); border-radius: 4px 4px 0 0; min-height: 4px; transition: height .5s; opacity: .85; }
.chart-label{ font-size: .65rem; color: var(--muted); text-align: center; }
.chart-val  { font-size: .7rem; color: var(--text); font-weight: 600; }

/* ─── LOADING / COMING SOON / RESTRICTED ─── */
.loading { text-align: center; padding: 3rem; color: var(--muted); font-size: .88rem; }
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--fdr-red);
  border-radius: 50%; animation: spin .7s linear infinite;
  margin-right: .5rem; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.coming-soon { text-align: center; padding: 4rem 2rem; }
.cs-icon     { margin-bottom: 1rem; opacity: .2; }
.cs-title    { font-size: 1.5rem; font-weight: 700; margin-bottom: .5rem; color: var(--text); }
.cs-sub      { color: var(--muted); font-size: .88rem; }
.restricted  { text-align: center; padding: 4rem 2rem; }

/* ─── DASHBOARD ─── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1rem; }
@media (min-width: 769px) and (max-width: 1023px) {
  .dash-charts-grid { gap: .8rem; padding: .8rem; }
}
@media (max-width: 768px) {
  .dash-charts-grid { grid-template-columns: 1fr; gap: .7rem; padding: .7rem; }
}
.dash-chart-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px; padding: .9rem; min-width: 0;
}
.dash-chart-label {
  font-size: .6rem; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .12em; margin-bottom: .7rem;
}

/* ─── NOTIFICACIONES ─── */
#notif-panel {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}
#notif-panel * { color: var(--text); }
