:root {
  --bg: #f4f4f7;
  --surface: #ffffff;
  --border: #e4e4ea;
  --text: #1a1a24;
  --muted: #6b7280;
  --primary: #7C3AED;
  --primary-soft: #ede9fe;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --radius: 12px;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
a { color: var(--primary); text-decoration: none; }

/* Buttons */
.btn { border: 1px solid transparent; border-radius: 9px; padding: 9px 14px; font-weight: 600;
  font-size: .86rem; cursor: pointer; font-family: inherit; background: var(--surface); color: var(--text); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: #0000000a; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-success { background: var(--success); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px; width: 320px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 12px 40px #0000000f; }
.brand { font-size: 1.6rem; font-weight: 800; }
.login-card input { padding: 11px 13px; border: 1px solid var(--border); border-radius: 9px; font-size: .95rem; }
.login-err { color: var(--danger); font-size: .82rem; min-height: 1em; }

/* Topbar */
.topbar { height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px; position: sticky; top: 0; z-index: 10; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.brand-sm { font-weight: 800; font-size: 1.05rem; }
.negocio-sel { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: .86rem;
  font-weight: 600; background: var(--bg); }

/* Layout */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 210px; background: var(--surface); border-right: 1px solid var(--border); padding: 12px 8px; flex: 0 0 auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  color: var(--muted); font-weight: 600; cursor: pointer; margin-bottom: 2px; }
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.content { flex: 1; padding: 24px; min-width: 0; }
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; display: flex; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .nav-item { white-space: nowrap; margin-bottom: 0; }
}

/* Page */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 1.4rem; margin: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.7rem; font-weight: 800; margin-top: 4px; }

/* Table */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: .86rem; white-space: nowrap; }
th { background: var(--bg); color: var(--muted); font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .5px; }
tr:last-child td { border-bottom: none; }
td .row-actions { display: flex; gap: 6px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.badge.draft { background: #f1f5f9; color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 40px; }

/* Forms */
.form-grid { display: grid; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: .78rem; font-weight: 700; color: var(--muted); }
.field input, .field select, .field textarea { padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: .9rem; font-family: inherit; background: var(--surface); color: var(--text); }
.field .hint { font-size: .72rem; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { flex-direction: row; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; }

/* Product form two-column */
.prod-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .prod-layout { grid-template-columns: 1fr; } }
.calc-panel { position: sticky; top: 72px; background: #14141c; color: #ececf0; border-radius: var(--radius); padding: 18px; font-variant-numeric: tabular-nums; }
.calc-panel h3 { margin: 0 0 12px; font-size: .9rem; color: #a78bfa; }
.calc-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: .84rem; }
.calc-line.dim { color: #9ca3af; }
.calc-sep { border-top: 1px dashed #ffffff2a; margin: 8px 0; }
.calc-line.total { font-weight: 800; font-size: .95rem; }
.calc-line.channel { font-weight: 700; }
.calc-channel-margin { font-size: .72rem; color: #9ca3af; }
.calc-warn { color: #f87171; font-size: .78rem; margin-top: 8px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: #0006; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; padding: 22px; }
.modal h2 { margin: 0 0 16px; font-size: 1.15rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #14141c; color: #fff; padding: 11px 20px; border-radius: 999px; font-size: .86rem;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; box-shadow: 0 8px 24px #0004; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

.spinner { text-align: center; color: var(--muted); padding: 40px; }
