/* ============================================================
   PULPERÍA ASOMECSA — Sistema de diseño
   Paleta Grupo Mecsa: navy #013483 · ámbar #F29C2E · fresh green
   Hand-written CSS (sin Bootstrap, sin build) — estilo SiteFlow.
   ============================================================ */
:root {
  /* Marca */
  --brand:        #013483;   /* navy Mecsa */
  --brand-600:    #012a6b;
  --brand-700:    #001f52;
  --brand-050:    #e7edf7;
  --accent:       #F29C2E;   /* ámbar */
  --accent-600:   #d9861a;
  --fresh:        #16A34A;   /* verde abarrotes */
  --fresh-050:    #e8f7ee;

  /* Superficies */
  --bg:           #f4f6fb;
  --surface:      #ffffff;
  --surface-2:    #fafbfe;
  --border:       #e4e8f0;
  --border-2:     #d5dbe7;

  /* Texto */
  --text:         #16233b;
  --text-soft:    #48566e;
  --text-muted:   #8a93a6;
  --on-brand:     #ffffff;

  /* Semántico */
  --success:      #16A34A;
  --success-050:  #e8f7ee;
  --danger:       #dc2626;
  --danger-050:   #fdecec;
  --warning:      #F29C2E;
  --warning-050:  #fef3e2;
  --info:         #2563eb;
  --info-050:     #e8f0fe;

  /* Layout */
  --sidebar-w:    250px;
  --sidebar-w-collapsed: 72px;
  --topbar-h:     62px;

  /* Forma */
  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    18px;
  --shadow-sm:    0 1px 2px rgba(16,35,59,.06);
  --shadow:       0 4px 16px rgba(16,35,59,.08);
  --shadow-lg:    0 12px 32px rgba(16,35,59,.14);

  --font:         'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14.5px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }

/* ---------------- App shell (grid) ---------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
  transition: grid-template-columns .2s ease;
}
.app.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.sidebar-workspace {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
.ws-logo, .ws-logo-img {
  width: 38px; height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  color: #fff; font-size: 18px;
  object-fit: cover;
}
.ws-info { overflow: hidden; }
.ws-name { font-weight: 800; font-size: 15px; letter-spacing: -.2px; white-space: nowrap; }
.ws-badge { font-size: 10.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 10px 12px 20px; }
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.sidebar-section { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.sidebar-group-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-muted);
  padding: 10px 12px 4px;
}
.sidebar-sep { border: none; border-top: 1px solid var(--border); margin: 8px 6px; }

.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-soft); font-weight: 600; font-size: 13.5px;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--brand-050); color: var(--brand); }
.nav-icon { width: 20px; text-align: center; font-size: 15px; color: var(--text-muted); flex-shrink: 0; }
.nav-link.active .nav-icon { color: var(--brand); }

.app.sidebar-collapsed .ws-info,
.app.sidebar-collapsed .sidebar-group-label,
.app.sidebar-collapsed .nav-link span { display: none; }
.app.sidebar-collapsed .nav-link { justify-content: center; }

/* ---------------- Topbar ---------------- */
.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-toggle {
  border: none; background: transparent; color: var(--text-soft);
  width: 38px; height: 38px; border-radius: 9px; cursor: pointer; font-size: 16px;
}
.topbar-toggle:hover { background: var(--surface-2); }
.topbar-breadcrumb { display: flex; align-items: center; gap: 8px; flex: 1; font-size: 13px; overflow: hidden; }
.bc-link { color: var(--text-muted); font-weight: 600; }
.bc-link:hover { color: var(--brand); }
.bc-sep { font-size: 9px; color: var(--border-2); }
.bc-current { color: var(--text); font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-role-pill {
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px;
  background: var(--accent); color: #3a2600;
  padding: 4px 10px; border-radius: 999px;
}
.topbar-icon-btn {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  color: var(--text-soft);
}
.topbar-icon-btn:hover { background: var(--surface-2); color: var(--danger); }
.topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  color: #fff; font-weight: 700; display: grid; place-items: center;
}

/* ---------------- Main ---------------- */
.main { grid-area: main; padding: 24px 28px 60px; overflow-x: hidden; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.4px; margin: 0; }
.page-subtitle { color: var(--text-muted); font-size: 13.5px; margin: 3px 0 0; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-body { padding: 18px 20px; }
.card-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-weight: 700; font-size: 15px; margin: 0; }

/* KPI stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 14px;
}
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; flex-shrink: 0; }
.stat-icon.brand   { background: var(--brand-050); color: var(--brand); }
.stat-icon.accent  { background: var(--warning-050); color: var(--accent-600); }
.stat-icon.fresh   { background: var(--fresh-050); color: var(--fresh); }
.stat-icon.danger  { background: var(--danger-050); color: var(--danger); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; font-family: var(--font); font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: filter .12s, background .12s, box-shadow .12s; line-height: 1;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary  { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-accent   { background: var(--accent); color: #3a2600; }
.btn-accent:hover:not(:disabled) { background: var(--accent-600); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(.94); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.94); }
.btn-ghost    { background: var(--surface); color: var(--text-soft); border-color: var(--border-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 20px; font-size: 15px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-icon { padding: 8px 10px; }

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-soft); margin-bottom: 6px; }
.form-control, select.form-control, textarea.form-control {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); font-family: var(--font); font-size: 14px;
  color: var(--text); background: var(--surface); transition: border .12s, box-shadow .12s;
}
.form-control:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(1,52,131,.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; }
.input-icon .form-control { padding-left: 34px; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); font-weight: 700; padding: 11px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- Badges ---------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge-success { background: var(--success-050); color: var(--success); }
.badge-danger  { background: var(--danger-050);  color: var(--danger); }
.badge-warning { background: var(--warning-050); color: var(--accent-600); }
.badge-info    { background: var(--info-050);    color: var(--info); }
.badge-muted   { background: var(--surface-2);   color: var(--text-muted); border: 1px solid var(--border); }

/* ---------------- Alerts ---------------- */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 15px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; margin-bottom: 16px; }
.alert-error   { background: var(--danger-050);  color: var(--danger); }
.alert-success { background: var(--success-050); color: var(--success); }
.alert-info    { background: var(--info-050);    color: var(--info); }
.alert-warning { background: var(--warning-050); color: var(--accent-600); }

/* ---------------- Login ---------------- */
.login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 100% 0%, rgba(242,156,46,.14), transparent 60%),
    radial-gradient(1000px 500px at 0% 100%, rgba(1,52,131,.12), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 34px 30px;
}
.login-logo { width: 62px; height: 62px; border-radius: 16px; margin: 0 auto 16px;
  display: grid; place-items: center; font-size: 28px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-600)); box-shadow: var(--shadow); }
.login-card h1 { text-align: center; font-size: 22px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.4px; }
.login-card .subtitle { text-align: center; color: var(--text-muted); font-size: 13px; font-weight: 600; margin-bottom: 24px; }

/* ---------------- Utilities ---------------- */
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.w-full { width: 100%; }
.grid { display: grid; }
.hidden { display: none; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; color: var(--border-2); display: block; }

/* ---------------- Responsive ---------------- */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; width: var(--sidebar-w);
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .main { padding: 18px 16px 50px; }
  .form-row { grid-template-columns: 1fr; }
}
