@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Lora:wght@500;600&display=swap');

/* ── RESET & BASE ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #f7f6f3;
  --surface:      #ffffff;
  --border:       #e8e5df;
  --text:         #1c1a17;
  --muted:        #8a8070;
  --accent:       #c8955a;
  --accent-light: #f5ede3;
  --accent-dark:  #a87340;
  --green:        #4a7c59;
  --green-light:  #e8f0eb;
  --red:          #b5433a;
  --red-light:    #f7ebe9;
  --blue:         #3a5f8a;
  --blue-light:   #e8eef5;
  --radius:       10px;
  --shadow:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  overflow: hidden;
  font-size: 14px;
}

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── LAYOUT ──────────────────────────────────────────────── */
#sidebar-container { display: flex; flex-shrink: 0; }

#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── HEADER ──────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.header-title { font-family: 'Lora', serif; font-size: 18px; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 16px; }

.badge-alert {
  background: var(--red-light);
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.user-avatar {
  width: 24px; height: 24px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 600;
}

/* ── CONTENT ─────────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
#sidebar {
  width: 220px;
  background: var(--text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .25s;
}
#sidebar.collapsed { width: 56px; }

.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  overflow: hidden;
}
.logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 15px;
  flex-shrink: 0;
}
.logo-text { color: #fff; font-family: 'Lora', serif; font-size: 15px; }
.logo-sub  { color: #8a8070; font-size: 11px; }

#sidebar nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: #8a8070; cursor: pointer;
  font-size: 13px; font-weight: 500;
  font-family: 'Inter', sans-serif;
  transition: all .15s;
  white-space: nowrap; overflow: hidden;
  border: none; background: none;
  width: 100%; text-align: left;
}
.nav-item:hover  { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.active { color: #fff; background: rgba(200,149,90,.18); }
.nav-item.active .nav-icon { color: var(--accent); }

.nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }

#sidebar.collapsed .nav-label,
#sidebar.collapsed .logo-text,
#sidebar.collapsed .logo-sub { display: none; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.collapse-btn {
  width: 100%; padding: 8px 10px;
  border-radius: 8px;
  background: none; border: none;
  color: #5a5245; cursor: pointer;
  font-size: 12px; font-family: 'Inter', sans-serif;
  display: flex; align-items: center; gap: 8px;
  transition: color .15s;
}
.collapse-btn:hover { color: #fff; }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-weight: 600; font-size: 14px; }

/* ── STAT CARDS ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 22px; font-weight: 600; color: var(--text); }
.stat-sub   { font-size: 11px; color: var(--muted); }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red   { background: var(--red-light);   color: var(--red);   }
.badge-blue  { background: var(--blue-light);  color: var(--blue);  }
.badge-amber { background: var(--accent-light); color: var(--accent-dark); }
.badge-gray  { background: #f0ede8; color: var(--muted); }

/* ── TABLE ───────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
  background: #faf9f7;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid #f2f0ec; transition: background .1s; }
tbody tr:hover { background: #faf9f6; }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 12px 16px; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; transition: all .15s;
  font-family: 'Inter', sans-serif;
}
.btn-primary           { background: var(--accent); color: #fff; }
.btn-primary:hover     { background: var(--accent-dark); }
.btn-primary:disabled  { opacity: .4; cursor: not-allowed; }
.btn-outline           { background: none; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover     { border-color: var(--accent); color: var(--accent); }
.btn-sm                { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-ghost {
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  font-size: 12px; font-family: 'Inter', sans-serif;
}
.btn-ghost:hover { color: var(--red); }

/* ── INPUTS ──────────────────────────────────────────────── */
input, select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: 'Inter', sans-serif; font-size: 13px;
  background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }
label {
  display: block;
  font-size: 12px; font-weight: 500;
  color: var(--muted); margin-bottom: 5px;
}

.search-wrap          { position: relative; }
.search-wrap input    { padding-left: 32px; }
.search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted); font-size: 14px;
  pointer-events: none;
}

/* ── FILTER PILLS ────────────────────────────────────────── */
.filter-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-btn {
  padding: 5px 14px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
  cursor: pointer; transition: all .15s;
  font-family: 'Inter', sans-serif;
}
.filter-btn.active              { background: var(--text); color: #fff; border-color: var(--text); }
.filter-btn:not(.active):hover  { border-color: var(--accent); color: var(--accent); }

/* ── PAGES ───────────────────────────────────────────────── */
.page        { display: none; }
.page.active { display: block; }

.page-header {
  margin-bottom: 20px;
  display: flex; align-items: flex-end; justify-content: space-between;
}
.page-title { font-family: 'Lora', serif; font-size: 22px; }
.page-sub   { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
  width: 100%; max-width: 440px;
  animation: fadeUp .2s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header  { padding: 20px 24px 0; }
.modal-title   { font-family: 'Lora', serif; font-size: 18px; }
.modal-body    { padding: 16px 24px; }
.modal-footer  { padding: 0 24px 20px; display: flex; gap: 10px; }
.form-row      { margin-bottom: 14px; }
.form-grid     { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── POS ─────────────────────────────────────────────────── */
.pos-layout    { display: flex; gap: 20px; flex: 1; min-height: 0; }
.pos-products  {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.pos-cart      {
  width: 320px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  min-height: 0;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; overflow-y: auto; padding-right: 4px;
}
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px; cursor: pointer;
  transition: all .15s; text-align: left;
  font-family: 'Inter', sans-serif;
}
.product-card:hover    { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.product-card:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.product-emoji  { font-size: 26px; margin-bottom: 8px; display: block; }
.product-name   { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.3; margin-bottom: 4px; }
.product-price  { font-size: 13px; font-weight: 600; color: var(--accent); }
.product-stock  { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── CART ────────────────────────────────────────────────── */
.cart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: hidden; height: 100%;
}
.cart-items { flex: 1; overflow-y: auto; }
.cart-item  { padding: 10px 14px; border-bottom: 1px solid #f2f0ec; }
.cart-item-name { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.cart-item-row  { display: flex; align-items: center; justify-content: space-between; }

.qty-ctrl { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.qty-btn  { width: 26px; height: 26px; border: none; background: none; cursor: pointer; font-size: 14px; color: var(--muted); transition: background .1s; font-family: 'Inter', sans-serif; }
.qty-btn:hover { background: var(--bg); }
.qty-val  { width: 28px; text-align: center; font-size: 13px; font-weight: 600; }

.cart-empty      { padding: 40px 20px; text-align: center; color: var(--muted); }
.cart-empty-icon { font-size: 36px; margin-bottom: 8px; opacity: .4; }

.cart-totals { padding: 14px; border-top: 1px solid var(--border); background: #faf9f7; }
.total-row   { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.total-row.big {
  font-size: 16px; font-weight: 600; color: var(--text);
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
}

.payment-methods { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin: 12px 0; }
.pay-btn {
  padding: 7px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 11px; font-weight: 600; cursor: pointer;
  text-align: center; color: var(--muted);
  transition: all .15s; font-family: 'Inter', sans-serif;
}
.pay-btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }

/* ── RECEIPT ─────────────────────────────────────────────── */
.receipt {
  max-width: 360px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.receipt-header { background: var(--text); color: #fff; padding: 24px; text-align: center; }
.receipt-body   { padding: 20px; font-size: 13px; }
.receipt-row    { display: flex; justify-content: space-between; padding: 4px 0; }
.receipt-divider { border: none; border-top: 1px dashed var(--border); margin: 10px 0; }

/* ── CLIENTS ─────────────────────────────────────────────── */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 12px; }
.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  transition: box-shadow .15s;
}
.client-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.client-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-light); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px; margin-bottom: 10px;
}
.client-name  { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.client-info  { font-size: 12px; color: var(--muted); line-height: 1.8; }
.client-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border); text-align: center;
}
.client-stat-val   { font-size: 16px; font-weight: 600; }
.client-stat-label { font-size: 11px; color: var(--muted); }

/* ── REPORTS ─────────────────────────────────────────────── */
.bar      { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .4s ease; }
.bar-accent { background: var(--accent); }
.bar-blue   { background: var(--blue); }

/* ── UTILITIES ───────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row    { display: flex; gap: 10px; align-items: center; }
.mb-16  { margin-bottom: 16px; }
.mt-16  { margin-top: 16px; }

/* ── PRINT ───────────────────────────────────────────────── */
@media print {
  body > * { display: none !important; }
  .receipt { display: block !important; max-width: 100%; border: none; }
}

/* ── SUPPLIERS ───────────────────────────────────────────── */
.supplier-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 12px; }

.supplier-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
  cursor: pointer;
}
.supplier-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }

.supplier-card-header {
  padding: 16px 18px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.supplier-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-light); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.supplier-name  { font-weight: 600; font-size: 14px; }
.supplier-rfc   { font-size: 11px; color: var(--muted); font-family: monospace; }

.supplier-card-body { padding: 14px 18px; }
.supplier-info  { font-size: 12px; color: var(--muted); line-height: 2; }

.supplier-card-footer {
  padding: 10px 18px;
  background: #faf9f7;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.supplier-prod-count { font-size: 12px; font-weight: 600; color: var(--text); }
.supplier-prod-label { font-size: 11px; color: var(--muted); }

/* Detail panel (slide-in overlay) */
.supplier-detail-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.25);
  z-index: 90;
  display: flex; justify-content: flex-end;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.supplier-detail-panel {
  width: 480px; max-width: 100%;
  background: var(--surface);
  height: 100%; overflow-y: auto;
  box-shadow: -8px 0 32px rgba(0,0,0,.1);
  animation: slideIn .25s ease;
  display: flex; flex-direction: column;
}
@keyframes slideIn { from { transform: translateX(40px); opacity:0; } to { transform: translateX(0); opacity:1; } }

.detail-panel-header {
  padding: 20px 24px;
  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: 1;
}
.detail-panel-title { font-family: 'Lora', serif; font-size: 18px; }
.detail-panel-body  { padding: 20px 24px; flex: 1; }

.detail-section       { margin-bottom: 24px; }
.detail-section-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }

.detail-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-info-item { background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.detail-info-key  { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.detail-info-val  { font-size: 13px; font-weight: 600; }

.supplier-product-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid #f2f0ec;
}
.supplier-product-row:last-child { border-bottom: none; }
.supplier-product-info { display: flex; align-items: center; gap: 10px; }
.supplier-product-emoji { font-size: 20px; }

/* ── WAREHOUSES ──────────────────────────────────────────── */
.warehouse-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  height: calc(100vh - 160px);
}

/* Left panel — warehouse list */
.warehouse-list-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.warehouse-list-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.warehouse-list-scroll { flex: 1; overflow-y: auto; }

.warehouse-item {
  padding: 13px 16px;
  border-bottom: 1px solid #f2f0ec;
  cursor: pointer;
  transition: background .12s;
  display: flex; align-items: center; gap: 10px;
}
.warehouse-item:last-child { border-bottom: none; }
.warehouse-item:hover { background: #faf9f6; }
.warehouse-item.active { background: var(--accent-light); border-left: 3px solid var(--accent); }
.warehouse-item.active .warehouse-item-name { color: var(--accent-dark); }

.warehouse-icon {
  width: 34px; height: 34px;
  background: var(--bg);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.warehouse-item.active .warehouse-icon { background: var(--accent-light); }
.warehouse-item-name  { font-size: 13px; font-weight: 600; }
.warehouse-item-loc   { font-size: 11px; color: var(--muted); }
.warehouse-item-count { margin-left: auto; flex-shrink: 0; }

/* Right panel — products in selected warehouse */
.warehouse-detail-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}
.warehouse-detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.warehouse-detail-name { font-family: 'Lora', serif; font-size: 18px; }
.warehouse-detail-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.warehouse-stat-row    { display: flex; gap: 24px; }
.warehouse-stat        { text-align: center; }
.warehouse-stat-val    { font-size: 18px; font-weight: 600; }
.warehouse-stat-label  { font-size: 11px; color: var(--muted); }

.warehouse-products-wrap {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.warehouse-products-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 10px; align-items: center;
  flex-shrink: 0;
}
.warehouse-products-table { flex: 1; overflow-y: auto; }

.warehouse-empty {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--muted); padding: 40px;
}
.warehouse-empty-icon { font-size: 40px; margin-bottom: 10px; opacity: .35; }
/* ── NAV SEPARATOR & ADMIN ITEM ─────────────────────────── */
.nav-separator {
  height: 1px;
  background: rgba(255,255,255,.08);
  margin: 8px 10px;
}

.nav-item-admin { color: #a87340 !important; }
.nav-item-admin:hover  { background: rgba(200,149,90,.12) !important; }
.nav-item-admin.active { background: rgba(200,149,90,.22) !important; }

/* ── LOGIN ───────────────────────────────────────────────── */
/* (estilos inline en login.php para mantenerlo autocontenido) */
/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Ajustes para diferentes resoluciones
   ═══════════════════════════════════════════════════════════ */

/* ── Pantallas medianas (< 1200px): sidebar más angosto ─── */
@media (max-width: 1199px) {
  #sidebar               { width: 180px; }
  #sidebar.collapsed     { width: 50px; }

  .stat-grid             { grid-template-columns: repeat(2, 1fr); }
  .grid-2                { grid-template-columns: 1fr; }
  .dash-quick-nav        { grid-template-columns: repeat(2, 1fr); }
  .cred-stat-grid        { grid-template-columns: repeat(2, 1fr); }

  .warehouse-layout      { grid-template-columns: 240px 1fr; }
}

/* ── Pantallas pequeñas (< 900px): sidebar colapsado auto ─ */
@media (max-width: 899px) {

  /* Sidebar: siempre colapsado (solo iconos), sin botón de colapsar */
  #sidebar               { width: 50px !important; }
  .sidebar-logo          { padding: 14px 9px; justify-content: center; }
  .logo-text, .logo-sub  { display: none !important; }
  .sidebar-footer        { display: none; }
  #sidebar nav           { padding: 8px 5px; }
  .nav-label             { display: none !important; }
  .nav-item              { justify-content: center; padding: 10px 0; }
  .nav-icon              { width: auto; font-size: 18px; }
  .nav-separator         { margin: 6px 5px; }

  /* Header: compactar */
  header                 { padding: 10px 14px; gap: 8px; }
  .header-title          { font-size: 15px; }
  .user-chip             { font-size: 12px; padding: 5px 9px; gap: 6px; }
  .badge-alert           { display: none; } /* ocultar en móvil, ya se ve en stock */

  /* Content: menos padding */
  #content               { padding: 14px; }

  /* Grids */
  .stat-grid             { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
  .grid-2                { grid-template-columns: 1fr; gap: 10px; }
  .dash-quick-nav        { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .cred-stat-grid        { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* POS */
  .pos-layout            { flex-direction: column; height: auto; gap: 12px; }
  .pos-cart              { width: 100%; }

  /* Bodegas */
  .warehouse-layout      { grid-template-columns: 1fr; height: auto; }
  .warehouse-list-panel  { max-height: 260px; }

  /* Supplier detail */
  .supplier-detail-panel { width: 100% !important; }

  /* Modales: más anchos */
  .modal                 { max-width: 98vw !important; margin: 0 8px; }
}

/* ── Pantallas muy pequeñas (< 600px): móvil ────────────── */
@media (max-width: 599px) {

  /* Header: solo avatar + salir */
  .header-right          { gap: 8px; }
  .user-chip span:not(.user-avatar):not(.badge) { display: none; } /* ocultar nombre */
  .btn-outline.btn-sm    { font-size: 11px; padding: 4px 8px; }

  /* Stats: una sola columna */
  .stat-grid             { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-value            { font-size: 18px; }
  .cred-stat-grid        { grid-template-columns: 1fr 1fr; }
  .dash-quick-nav        { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .dash-qbtn             { padding: 10px 8px; }
  .dash-qbtn-icon        { font-size: 18px; }
  .dash-qbtn-label       { font-size: 11px; }
  .dash-qbtn-sub         { display: none; }

  /* Formularios: una columna */
  .form-grid             { grid-template-columns: 1fr; gap: 0; }
  .form-row              { margin-bottom: 10px; }

  /* Tablas: scroll horizontal */
  .card > table,
  .card > div > table    { min-width: 500px; }
  .card                  { overflow-x: auto; }

  /* Content */
  #content               { padding: 10px; }

  /* Page header */
  .page-header           { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
  .page-title            { font-size: 18px; }

  /* POS: lista de productos como lista simple */
  .pli                   { grid-template-columns: 36px 1fr 100px 32px; }
  .pli-stk               { display: none; }

  /* Client grid */
  .client-grid           { grid-template-columns: 1fr; }

  /* Supplier grid */
  .supplier-grid         { grid-template-columns: 1fr; }

  /* Filtros: scroll horizontal */
  .filter-row            { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .filter-btn            { flex-shrink: 0; }

  /* Bodegas */
  .warehouse-layout      { grid-template-columns: 1fr; }
  .warehouse-detail-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .warehouse-stat-row    { flex-wrap: wrap; gap: 12px; }

  /* Confirm modal POS */
  .confirm-modal         { width: 100% !important; max-height: 100vh; border-radius: 0; }
  .cm-info-grid          { grid-template-columns: 1fr; }
}

/* ── Header: evitar corte en cualquier resolución ────────── */
header {
  flex-wrap: wrap;
  min-height: 56px;
}
.header-right {
  flex-wrap: wrap;
  flex-shrink: 1;
  min-width: 0;
}

/* ── Sidebar: overflow-y para pantallas de poca altura ───── */
#sidebar {
  overflow-y: auto;
  overflow-x: hidden;
}
#sidebar nav {
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Pantallas de poca altura (landscape móvil) ──────────── */
@media (max-height: 600px) {
  #sidebar nav           { gap: 0; }
  .nav-item              { padding: 7px 10px; font-size: 12px; }
  .sidebar-logo          { padding: 10px 16px; }
  .sidebar-footer        { padding: 8px; }
  header                 { padding: 8px 16px; min-height: 48px; }
  #content               { padding: 12px 20px; }
}