:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #fff9e8;
  --text: #182033;
  --muted: #6d7483;
  --border: #e6e9ef;
  --primary: #ffb800;
  --primary-dark: #d99600;
  --success: #22a06b;
  --danger: #d64545;
  --info: #3b82f6;
  --shadow: 0 14px 35px rgba(23, 32, 51, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #171c28;
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 24px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #161616;
  font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; color: #aeb4c0; }

.side-nav {
  display: grid;
  gap: 7px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  padding: 0 13px;
  border-radius: 12px;
  color: #cfd4df;
  transition: .2s ease;
}

.side-nav a:hover,
.side-nav a.active {
  background: rgba(255, 184, 0, .14);
  color: #fff;
}

.side-nav a.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-note {
  margin-top: auto;
  padding: 15px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  background: rgba(255,255,255,.05);
}

.sidebar-note p {
  margin: 6px 0 0;
  color: #aeb4c0;
  font-size: 13px;
  line-height: 1.45;
}

.main-column { min-width: 0; }

.topbar {
  min-height: 90px;
  padding: 18px 30px;
  background: rgba(255,255,255,.95);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.topbar h1 { margin: 2px 0 0; font-size: 26px; }
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
}

.topbar-actions { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); }
.avatar {
  width: 42px;
  height: 42px;
  margin-left: 8px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--primary);
  color: #1b1b1b;
  font-weight: 800;
}

.page-content { padding: 30px; }

.hero-card {
  padding: 30px;
  border-radius: 22px;
  background: linear-gradient(135deg, #171c28, #30394f);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  box-shadow: var(--shadow);
}

.hero-card h2 { margin: 12px 0 10px; font-size: clamp(26px, 3vw, 38px); }
.hero-card p { max-width: 680px; margin: 0; color: #cbd0db; line-height: 1.6; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.soft { background: #fff3c7; color: #7b5600; }

.stats-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.stat-card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.stat-card p, .stat-card small { margin: 0; color: var(--muted); }
.stat-card strong { display: block; margin: 7px 0 3px; font-size: 26px; }

.stat-icon {
  flex: 0 0 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.stat-icon.yellow { background: #fff2bf; color: #8a6000; }
.stat-icon.blue { background: #e6efff; color: #255fc0; }
.stat-icon.green { background: #dff7ec; color: #13734b; }
.stat-icon.red { background: #ffe5e5; color: #a52c2c; }

.content-grid { margin-top: 22px; display: grid; gap: 18px; }
.content-grid.two-thirds { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }

.panel { padding: 22px; }
.panel-heading, .page-actions, .filters-row, .form-actions, .back-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.panel-heading { margin-bottom: 18px; }
.panel-heading h2 { margin: 3px 0 0; }
.page-actions { margin-bottom: 18px; }
.page-actions p { margin: 0; color: var(--muted); }

.btn {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.btn.primary { background: var(--primary); color: #1b1b1b; }
.btn.primary:hover { background: #ffc533; }
.btn.secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn.ghost { background: transparent; color: var(--muted); }
.full-button { width: 100%; }

.text-link { color: #9a6c00; font-weight: 700; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: #fafbfe; }

.status {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef1f6;
}
.status.enviado, .status.entregado { background: #dff7ec; color: #13734b; }
.status.cancelado { background: #ffe5e5; color: #a52c2c; }
.status.preparando { background: #e6efff; color: #255fc0; }
.status.pendiente-de-pago { background: #fff2bf; color: #8a6000; }

.stock-list { display: grid; gap: 12px; }
.stock-item {
  padding: 13px;
  border-radius: 12px;
  background: #fafbfe;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.stock-item small { color: var(--muted); }

.filters-row { margin-bottom: 18px; }
.search-field {
  flex: 1;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: #fff;
}
.search-field input { border: 0; outline: 0; width: 100%; }
select, input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}
.filters-row select { max-width: 230px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid label { display: grid; gap: 7px; font-weight: 600; }
.form-grid .full { grid-column: 1 / -1; }

.profile-layout, .import-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 20px;
}

.business-preview { text-align: center; }
.company-logo {
  width: 84px;
  height: 84px;
  margin: 18px auto;
  border-radius: 24px;
  background: var(--primary);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
}
.business-preview dl { text-align: left; }
.business-preview dl div {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.business-preview dt { color: var(--muted); font-size: 12px; }
.business-preview dd { margin: 5px 0 0; }

.drop-zone {
  min-height: 260px;
  margin-top: 20px;
  border: 2px dashed #d8dce5;
  border-radius: 18px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 25px;
  background: #fafbfe;
  cursor: pointer;
}
.drop-zone.dragover { border-color: var(--primary); background: #fffaf0; }
.upload-icon { font-size: 40px; color: #9a6c00; }
.drop-zone h3 { margin: 12px 0 6px; }
.drop-zone p, .drop-zone small, .muted, .mini-note { color: var(--muted); }

.file-info {
  margin-top: 14px;
  padding: 13px;
  background: #f6f7fa;
  border-radius: 11px;
}

.column-list { display: grid; gap: 9px; margin: 18px 0; }
.column-list span {
  padding: 10px 12px;
  background: #f7f8fb;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.column-list b { float: right; color: #9a6c00; font-size: 11px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(10,14,24,.55); }
.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
}
.mobile-menu { display: none; }

.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  padding: 13px 16px;
  border-radius: 11px;
  background: #171c28;
  color: #fff;
  box-shadow: var(--shadow);
}

.order-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 20px;
}
.detail-list { display: grid; gap: 12px; }
.detail-row { display: flex; justify-content: space-between; gap: 15px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid.two-thirds, .profile-layout, .import-layout, .order-detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -280px;
    width: 260px;
    transition: .25s ease;
  }
  .sidebar.open { left: 0; }
  .mobile-menu { display: inline-grid; place-items: center; }
  .topbar { padding: 15px 18px; }
  .page-content { padding: 18px; }
  .desktop-only { display: none; }
  .hero-card { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .filters-row, .page-actions { align-items: stretch; flex-direction: column; }
  .filters-row select { max-width: none; }
}
