/* ============================================================
   masymas · Back-office Central — Sistema de diseño
   Brand verde corporativo #005e49. Sin dependencias.
   ============================================================ */
:root {
  --brand: #005e49;
  --brand-2: #00715a;
  --brand-d: #003a2e;
  --brand-l: #e6f1ee;
  --brand-l2: #cfe3dd;
  --accent: #ffcc00;
  --accent-d: #f0b800;
  --red: #d33636;
  --red-l: #fbe9e9;
  --orange: #ff7a1a;
  --orange-l: #fff0e3;
  --blue: #2563eb;
  --blue-l: #e7eefc;
  --green-ok: #1f9d57;
  --green-l: #e4f5ea;
  --purple: #7e2d8f;

  --bg: #eef2f1;
  --panel: #ffffff;
  --panel-2: #f7faf9;
  --panel-3: #f0f4f3;
  --line: #e2e8e4;
  --line-2: #cdd6d1;

  --txt: #15211d;
  --txt-2: #4a574f;
  --txt-3: #7d8b84;

  --shadow: 0 1px 2px rgba(15,35,28,.05), 0 6px 18px rgba(15,35,28,.06);
  --shadow-lg: 0 24px 60px rgba(0,55,42,.22);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;

  --sidebar-w: 256px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--txt);
  background:
    radial-gradient(1200px 700px at -8% -12%, #e7efe9 0%, transparent 52%),
    radial-gradient(900px 560px at 112% -6%, #eaf2ee 0%, transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ============================================================
   Shell (sidebar + main)
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #f4f6f5 0%, #e9edeb 100%);
  color: var(--txt-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,.14); border-radius: 8px; }

.sb-brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; }
.sb-brand img { height: 30px; }            /* logo en su color original */
.sb-brand .sb-sub { font-size: 11px; letter-spacing: .04em; color: var(--txt-3); text-transform: uppercase; }
.sb-brand b { display: block; font-size: 15px; color: var(--txt); }

.sb-search { margin: 4px 14px 10px; }
.sb-search input {
  width: 100%; background: var(--panel); border: 1px solid var(--line-2);
  color: var(--txt); border-radius: 10px; padding: 9px 12px; font-size: 13px;
}
.sb-search input::placeholder { color: var(--txt-3); }
.sb-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-l); }

.sb-nav { padding: 4px 10px 18px; flex: 1; }
.sb-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--txt-3); padding: 14px 10px 6px; font-weight: 700; }
.sb-link {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 11px; border-radius: 10px; color: var(--txt-2); font-size: 13.5px; font-weight: 500;
  text-align: left; transition: background .12s, color .12s; position: relative;
}
.sb-link svg { width: 18px; height: 18px; flex: none; opacity: .75; }
.sb-link:hover { background: rgba(0,0,0,.05); color: var(--txt); }
.sb-link.is-active { background: var(--brand-l); color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.sb-link.is-active svg { opacity: 1; }
.sb-link .sb-badge { margin-left: auto; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 800; padding: 1px 7px; border-radius: 20px; }
.sb-link .sb-badge.is-red { background: var(--red); color: #fff; }

.sb-foot { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--txt-3); }
.sb-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green-ok); margin-right: 6px; }

.main { display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 13px 26px;
  background: rgba(255,255,255,.72); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.topbar .crumb { font-size: 12px; color: var(--txt-3); margin-top: 1px; }
.topbar-spacer { flex: 1; }
.topbar .seg { display: flex; background: var(--panel-3); border-radius: 10px; padding: 3px; }
.topbar .seg button { padding: 6px 13px; font-size: 12.5px; border-radius: 8px; color: var(--txt-2); font-weight: 600; }
.topbar .seg button.is-active { background: var(--panel); color: var(--brand); box-shadow: var(--shadow); }
.topbar .pill { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--txt-2); background: var(--panel); border: 1px solid var(--line); padding: 7px 12px; border-radius: 10px; }
.topbar .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }

.content { padding: 22px 26px 60px; }

/* ============================================================
   Tipografía utilitaria
   ============================================================ */
.h-sec { font-size: 14px; font-weight: 700; margin: 26px 0 12px; display: flex; align-items: center; gap: 9px; }
.h-sec:first-child { margin-top: 4px; }
.h-sec .sub { font-weight: 500; color: var(--txt-3); font-size: 12.5px; }
.muted { color: var(--txt-3); }
.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }

/* ============================================================
   Tarjetas / paneles
   ============================================================ */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.card-head .muted { font-size: 12px; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-6 { grid-template-columns: repeat(6, 1fr); }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
@media (max-width: 1180px) { .g-4 { grid-template-columns: repeat(2,1fr);} .g-6{grid-template-columns:repeat(3,1fr);} .g-3{grid-template-columns:repeat(2,1fr);} }

/* KPI tile */
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 17px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi-k { font-size: 12px; color: var(--txt-3); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.kpi-k svg { width: 15px; height: 15px; color: var(--brand); }
.kpi-v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 7px; font-variant-numeric: tabular-nums; }
.kpi-d { font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 5px; color: var(--txt-3); }
.kpi-d.up { color: var(--green-ok); } .kpi-d.down { color: var(--red); }
.kpi-spark { position: absolute; right: 0; bottom: 0; opacity: .9; }
.kpi-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); }

/* ============================================================
   Badges / chips / estados
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; line-height: 1.4; }
.badge .b-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-ok    { background: var(--green-l); color: #167a42; }
.b-warn  { background: var(--orange-l); color: #b85c00; }
.b-down, .b-err { background: var(--red-l); color: var(--red-d, #b02525); }
.b-info  { background: var(--blue-l); color: #1b4fd1; }
.b-neutral { background: var(--panel-3); color: var(--txt-2); }
.b-brand { background: var(--brand-l); color: var(--brand); }
.b-accent { background: #fff5cc; color: #8a6d00; }
.b-purple { background: #f2e6f5; color: var(--purple); }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 20px; background: var(--panel-3); color: var(--txt-2); border: 1px solid var(--line); }
.chip.is-on { background: var(--brand-l); color: var(--brand); border-color: var(--brand-l2); }
.dotcol { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* sección color tag */
.sec-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.sec-tag .dotcol { width: 10px; height: 10px; }

/* ============================================================
   Botones
   ============================================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; border-radius: 10px; font-size: 13px; font-weight: 600; background: var(--panel); border: 1px solid var(--line-2); color: var(--txt); transition: .12s; }
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-pri { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-pri:hover { background: var(--brand-2); color: #fff; }
.btn-accent { background: var(--accent); color: #3a2e00; border-color: var(--accent-d); }
.btn-accent:hover { background: var(--accent-d); color: #3a2e00; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--txt-2); }
.btn-ghost:hover { background: var(--panel-3); color: var(--txt); }
.btn-danger { color: var(--red); border-color: #ecc9c9; }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn-xs { padding: 4px 9px; font-size: 11.5px; border-radius: 7px; }
.btn-block { width: 100%; }
/* Exportar a Power BI */
.btn-pbi { background: #f2c811; color: #3a2e00; border-color: #e0b400; font-weight: 700; }
.btn-pbi:hover { background: #e0b400; color: #3a2e00; border-color: #c99f00; }
.btn-pbi svg { color: #3a2e00; }

/* ============================================================
   Tablas densas
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-weight: 600; color: var(--txt-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); position: sticky; top: 0; }
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--panel-2); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl .strong { font-weight: 700; }
table.tbl .t-main { font-weight: 600; }
table.tbl .t-sub { font-size: 11.5px; color: var(--txt-3); }
.tbl-zebra tbody tr:nth-child(even) { background: var(--panel-2); }
.tbl-compact th, .tbl-compact td { padding: 8px 12px; }

/* mini avatar inicial */
.ava { width: 30px; height: 30px; border-radius: 9px; background: var(--brand-l); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.cell-emp { display: flex; align-items: center; gap: 10px; }

/* progress bar */
.bar { height: 7px; background: var(--panel-3); border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.bar.thin { height: 5px; }

/* meter (score) */
.meter { display: inline-flex; align-items: center; gap: 8px; min-width: 110px; }
.meter .bar { flex: 1; }
.meter b { font-size: 12px; min-width: 28px; text-align: right; }

/* ============================================================
   Formularios
   ============================================================ */
.field { display: block; margin-bottom: 13px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--txt-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; font-size: 13.5px; background: var(--panel); color: var(--txt);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-l); }
.field-row { display: flex; gap: 12px; } .field-row .field { flex: 1; }
.help { font-size: 11.5px; color: var(--txt-3); margin-top: 4px; }

/* Selector de tiendas (p.ej. Nueva promoción) */
.np-stores-toolbar { display: flex; gap: 8px; align-items: center; margin: 6px 0 8px; }
.np-stores-toolbar .input-icn { flex: 1; }
.np-stores { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 2px 8px 6px; background: var(--panel); }
.np-store-grp + .np-store-grp { border-top: 1px solid var(--line); }
.np-store-grp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 2px 5px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.np-store-grp-head b { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--txt-3); font-weight: 700; }
.np-store { display: grid; grid-template-columns: 18px 40px 1fr auto; align-items: center; gap: 10px; padding: 6px 6px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.np-store:hover { background: var(--panel-3); }
.np-store input[type="checkbox"] { width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--brand); cursor: pointer; }
.np-store .np-code { font-family: var(--mono); font-size: 11.5px; color: var(--txt-3); }
.np-store .np-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.np-store .np-city { font-size: 11.5px; color: var(--txt-3); white-space: nowrap; }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 40px; height: 23px; flex: none; }
.switch input { display: none; }
.switch i { position: absolute; inset: 0; background: var(--line-2); border-radius: 20px; transition: .15s; }
.switch i::after { content:''; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(17px); }

/* ============================================================
   Tabs (sub-navegación dentro de una vista)
   ============================================================ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { padding: 10px 15px; font-size: 13px; font-weight: 600; color: var(--txt-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--txt); }
.tabs button.is-active { color: var(--brand); border-bottom-color: var(--brand); }

/* toolbar (filtros encima de tabla) */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.input-icn { position: relative; }
.input-icn svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--txt-3); }
.input-icn input { padding: 9px 12px 9px 34px; border: 1px solid var(--line-2); border-radius: 10px; font-size: 13px; min-width: 240px; }
select.sel { padding: 9px 30px 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; font-size: 13px; background: var(--panel); }

/* ============================================================
   Listas KV / detalle
   ============================================================ */
.kvlist { display: grid; gap: 0; }
.kvlist .kvrow { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.kvlist .kvrow:last-child { border-bottom: 0; }
.kvlist .kvrow span { color: var(--txt-3); }
.kvlist .kvrow b { font-weight: 600; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--txt-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* empty/info note */
.note { background: var(--panel-2); border: 1px dashed var(--line-2); border-radius: 12px; padding: 14px 16px; font-size: 13px; color: var(--txt-2); display: flex; gap: 10px; }
.note svg { width: 18px; height: 18px; color: var(--brand); flex: none; margin-top: 1px; }
.note.warn { background: var(--orange-l); border-color: #f3d3ac; color: #8a4a00; }
.note.warn svg { color: var(--orange); }

/* code block */
.code { background: #0f211c; color: #d7efe6; border-radius: 12px; padding: 14px 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; overflow-x: auto; }
.code .k { color: #ffcc00; } .code .s { color: #8fd6b6; } .code .c { color: #6f8c82; }
.method { font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.m-get { background: var(--blue-l); color: #1b4fd1; }
.m-post { background: var(--green-l); color: #167a42; }
.m-put { background: var(--orange-l); color: #b85c00; }
.m-del { background: var(--red-l); color: var(--red); }

/* ============================================================
   Charts (SVG inline) — helpers visuales
   ============================================================ */
.chart { width: 100%; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-lbl { fill: var(--txt-3); font-size: 10px; font-family: var(--font); }
.bars-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; }
.bars-row .bl { width: 150px; color: var(--txt-2); display: flex; align-items: center; gap: 7px; }
.bars-row .bt { flex: 1; }
.bars-row .bv { width: 92px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* heat dots para tiendas */
.storegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px,1fr)); gap: 6px; }
.storedot { aspect-ratio: 1; border-radius: 7px; display: grid; place-items: center; font-size: 9.5px; font-weight: 700; color: #fff; cursor: pointer; }

/* ============================================================
   Modal
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: 100; display: none; }
.modal.is-open { display: block; }
.modal-bg { position: absolute; inset: 0; background: rgba(8,24,19,.5); backdrop-filter: blur(2px); }
.modal-panel { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); background: var(--panel); border-radius: 18px; box-shadow: var(--shadow-lg); width: min(560px, 94vw); max-height: 90vh; overflow-y: auto; }
.modal-panel.lg { width: min(880px, 95vw); }
.modal-panel.xl { width: min(1100px, 96vw); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-head .modal-x { margin-left: auto; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--txt-3); }
.modal-head .modal-x:hover { background: var(--panel-3); color: var(--txt); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--panel); }

/* ============================================================
   Toast
   ============================================================ */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 80px); background: #15211d; color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; transition: .25s; z-index: 200; pointer-events: none; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-ok { background: var(--brand); } .toast.is-err { background: var(--red); }

/* tiny scrollbars */
.content::-webkit-scrollbar, .table-wrap::-webkit-scrollbar, .modal-panel::-webkit-scrollbar { height: 9px; width: 9px; }
.content::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb, .modal-panel::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }

/* util spacing */
.mt0{margin-top:0}.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mt24{margin-top:24px}
.mb0{margin-bottom:0}.mb8{margin-bottom:8px}.mb12{margin-bottom:12px}.mb16{margin-bottom:16px}
.flex{display:flex}.aic{align-items:center}.jcsb{justify-content:space-between}.gap8{gap:8px}.gap12{gap:12px}.wrap{flex-wrap:wrap}.grow{flex:1}
.tr{text-align:right}.tc{text-align:center}
.fz12{font-size:12px}.fz13{font-size:13px}.fw7{font-weight:700}
.hide{display:none}
