:root {
  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --sport: #0f766e;
  --sport-dark: #115e59;
  --sport-light: #ccfbf1;
  --flame: #ea580c;
  --danger: #dc2626;
  --success: #059669;
  --warning: #d97706;
  --info: #0284c7;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --topbar-h: 60px;
  --sidebar-w: 260px;
  --touch: 44px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; font-size: 1rem; }
a { color: var(--sport); text-decoration: none; }
h1,h2,h3,h4 { margin: 0 0 .5rem; line-height: 1.2; }

.app-body { overflow-x: hidden; }
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: min(86vw, var(--sidebar-w));
  background: var(--ink); color: #fff; z-index: 50;
  transform: translateX(-105%); transition: transform .22s ease;
  display: flex; flex-direction: column;
}
.sidebar.open { transform: translateX(0); }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 40;
}
.sidebar-backdrop.show { display: block; }
.sidebar-brand {
  display: flex; align-items: center; gap: 12px; padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: #fff; }
.sidebar-brand strong { display: block; font-size: .95rem; }
.sidebar-brand span { display: block; font-size: .75rem; color: #94a3b8; }
.sidebar-close {
  margin-left: auto; background: transparent; border: 0; color: #fff;
  width: var(--touch); height: var(--touch); border-radius: 10px;
}
.sidebar-nav { overflow: auto; padding: 10px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px; color: #cbd5e1;
  padding: 11px 12px; border-radius: 12px; min-height: var(--touch);
}
.nav-link i { width: 20px; text-align: center; }
.nav-link.active, .nav-link:hover { background: rgba(20,184,166,.16); color: #fff; }
.sidebar-user {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); gap: 8px;
}
.sidebar-user span { display: block; color: #94a3b8; font-size: .75rem; }
.app-main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.05rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.page-content { padding: 14px; max-width: 1600px; }

.icon-btn {
  width: var(--touch); height: var(--touch); display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: #fff; border-radius: 12px; color: var(--ink); box-shadow: 0 1px 0 var(--line);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch); padding: 0 14px; border-radius: 12px; border: 0; cursor: pointer;
  font-weight: 600; white-space: nowrap;
}
.btn-primary { background: var(--sport); color: #fff; }
.btn-primary:hover { background: var(--sport-dark); }
.btn-flame { background: var(--flame); color: #fff; }
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-whatsapp:hover { background: #1ebe5d; color: #fff; }
.btn-outline { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { min-height: 38px; padding: 0 10px; font-size: .9rem; }
.btn:disabled { opacity: .65; cursor: not-allowed; }
.btn span { display: none; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.stat-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
}
.action-grid {
  display: grid; grid-template-columns: 1fr; gap: 10px; margin: 14px 0;
}
.action-tile {
  display: flex; flex-direction: column; gap: 4px; background: #fff;
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  color: var(--ink); min-height: 88px;
}
.action-tile i { color: var(--sport); font-size: 1.3rem; }
.action-tile strong { font-size: 1.05rem; }
.action-tile span { color: var(--muted); font-size: .85rem; }
.action-tile-primary { background: var(--sport); color: #fff; }
.action-tile-primary i, .action-tile-primary span { color: #ccfbf1; }
.action-tile-primary strong { color: #fff; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0;
}
.stat-card span { color: var(--muted); font-size: .8rem; display: block; }
.stat-card strong { font-size: 1.15rem; display: block; margin-top: 4px; word-break: break-word; }
.stat-card i { color: var(--sport); margin-bottom: 6px; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .9rem; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #fff;
  min-height: var(--touch);
}
.field textarea { min-height: 90px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toolbar .field, .toolbar input, .toolbar select { flex: 1 1 140px; min-width: 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; min-width: 640px; }
table.data th, table.data td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.mobile-cards { display: grid; gap: 10px; }
.mobile-card {
  background: #fff; border-radius: 14px; padding: 12px; box-shadow: var(--shadow);
}
.mobile-card .row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; }
.mobile-card .row span { color: var(--muted); }
.hide-desktop { display: block; }
.hide-mobile { display: none; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; font-size: .75rem; font-weight: 700; }
.badge-btn {
  border: 0;
  cursor: pointer;
  font-family: inherit;
  min-height: 36px;
  padding: 6px 12px;
}
.badge-btn:hover, .badge-btn:focus-visible {
  filter: brightness(.96);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, .25);
  outline: none;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-muted { background: #e2e8f0; color: #334155; }
.badge-info { background: #e0f2fe; color: #075985; }

.return-stack { display: grid; gap: 8px; margin-top: 8px; }
.return-block {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 10px 12px;
}
.return-block-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.return-block-head strong { font-size: .92rem; }
.return-block-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-bottom: 8px;
}
.return-block-grid span {
  display: block; color: var(--muted); font-size: .75rem; font-weight: 600;
}
.return-block-grid strong { font-size: .9rem; word-break: break-word; }
.return-reason { grid-column: 1 / -1; }
table.data.return-items { min-width: 0; background: #fff; border-radius: 10px; }
table.data.return-items th, table.data.return-items td { padding: 7px 8px; }
tr.sale-return-row td { background: #fffaf5; border-bottom: 12px solid var(--bg); }

.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.pager { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: linear-gradient(160deg, #0f172a, #115e59);
}
.auth-card {
  width: 100%; max-width: 440px; background: #fff; border-radius: 20px; padding: 24px; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.4rem; }
.auth-logo { width: 56px; height: 56px; margin-bottom: 12px; }

.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 70;
  padding: 12px; overflow: auto;
}
.modal-overlay.show { display: flex; align-items: flex-end; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px;
}
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.return-modal { max-width: 760px; }
.return-modal .return-stack { margin-top: 0; }
body.modal-open { overflow: hidden; }
.modal {
  background: #fff; width: 100%; max-width: 720px; margin: auto; border-radius: 18px 18px 12px 12px;
  max-height: 92vh; overflow: auto; padding: 16px;
}
.product-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 10px; background: #e2e8f0; }

@media (min-width: 768px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.two, .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .btn span { display: inline; }
  .page-content { padding: 20px; }
  .modal-overlay { align-items: center; }
  .modal { border-radius: 18px; }
  .return-block-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .sidebar { transform: none; position: sticky; top: 0; height: 100vh; flex: 0 0 var(--sidebar-w); }
  .app-shell { display: flex; }
  .app-main { flex: 1; min-width: 0; }
  .menu-btn, .sidebar-close, .sidebar-backdrop { display: none !important; }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .action-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hide-desktop { display: none; }
  .hide-mobile { display: block; }
  table.data.responsive-cards { min-width: 0; }
  .hide-sm { display: inline; }
}

@media (min-width: 1440px) {
  .stat-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .page-content { padding: 24px 28px; }
}

@media (min-width: 1920px) {
  .page-content { max-width: 1800px; }
}

.hide-sm { display: none; }
.filters-drawer summary { cursor: pointer; font-weight: 700; padding: 8px 0; }
@media print {
  .sidebar, .topbar, .toolbar, .pos-cart-bar, .btn, .modal-overlay { display: none !important; }
  .app-shell, .app-main, .page-content { display: block !important; padding: 0 !important; }
  .card { box-shadow: none; }
}
.select2-container .select2-selection--single { min-height: var(--touch); padding-top: 6px; border-radius: 12px; }
