:root {
  --ink: #1c1915;
  --muted: #6d645b;
  --paper: #f4efe7;
  --card: #fffdf9;
  --line: #e4d9cc;
  --green: #1f4d3a;
  --clay: #b5522a;
  --gold: #c6a15b;
  --shadow: 0 12px 30px rgba(48, 32, 16, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 22px;
  background: #24312b;
  color: #f7f3ea;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 1.3rem; }
.eyebrow { font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.7; }
.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--gold);
  color: #2a2114;
  font-weight: 700;
}
.tabs { display: flex; gap: 8px; flex: 1; }
.tab, .btn, .chip, .icon-btn { border: 0; border-radius: 999px; }
.tab { background: transparent; color: inherit; padding: 8px 14px; }
.tab.active { background: rgba(255, 255, 255, 0.14); }
.tab span {
  display: inline-grid;
  place-items: center;
  min-width: 1.3rem;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gold);
  color: #2a2114;
  font-size: 0.78rem;
}
.link { color: #f7f3ea; }

.layout { padding: 20px; }
.toolbar, .section-head, .dialog-actions, .categoria-nueva, .metrics {
  display: flex;
  gap: 12px;
  align-items: center;
}
.toolbar { margin: 14px 0; }
.toolbar input[type="search"] { flex: 1; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
}
.metrics { margin-bottom: 8px; }
.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  min-width: 140px;
}
.metric strong { display: block; font-size: 1.3rem; }
.metric span { color: var(--muted); font-size: 0.85rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { background: transparent; border: 1px solid var(--line); padding: 7px 12px; }
.chip.active { background: var(--green); color: #f7f3ea; border-color: var(--green); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card, .pedido, dialog form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.card { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card header, .pedido header { display: flex; justify-content: space-between; gap: 8px; }
.codigo, .meta { color: var(--muted); font-size: 0.86rem; }
.precio { font-size: 1.15rem; font-weight: 700; }
.actions, .pedido-acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.actions { margin-top: auto; }
.btn { background: #efe7dc; padding: 9px 14px; }
.btn.primary { background: var(--green); color: #f7f3ea; }
.btn.danger { background: transparent; color: var(--clay); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.badge { font-size: 0.75rem; border-radius: 999px; padding: 3px 8px; background: #f3e2c4; }
.badge.bajo { background: #f6d2c6; color: #8a3418; }
.badge.off, .badge.cancelado { background: #ece7e1; color: var(--muted); }
.badge.pendiente { background: #f6e7c8; }
.badge.confirmado { background: #d7ebe3; color: #1e4a38; }
.badge.entregado { background: #e4e0f2; color: #3d3566; }

#lista-pedidos { display: flex; flex-direction: column; gap: 12px; }
.pedido { padding: 16px; }
.pedido ul { margin: 10px 0 0; padding-left: 18px; color: var(--muted); }
.hidden { display: none !important; }
.icon-btn { width: 32px; height: 32px; background: #efe7dc; font-size: 1.2rem; }
.check { display: flex; align-items: center; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.form-grid label, .check { font-size: 0.88rem; }
.form-grid .wide { grid-column: 1 / -1; }
.categoria-nueva { margin-bottom: 14px; }
.categoria-nueva input { flex: 1; }
.dialog-actions { justify-content: flex-end; }
.section-head { margin-bottom: 14px; }
.section-head p { color: var(--muted); margin-top: 4px; }

dialog { border: 0; padding: 0; background: transparent; width: min(640px, calc(100% - 24px)); }
dialog::backdrop { background: rgba(28, 25, 21, 0.45); }
dialog form { padding: 18px; }

.aviso {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink);
  color: #f7f3ea;
  padding: 12px 16px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}
.aviso.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 800px) {
  .topbar, .toolbar, .metrics { flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
}
