/* ============================================================
   Redes y Bigotes — Panel de Administración
   Sistema de diseño: "Bosque & Tierra"
   Sensación: calma, bienestar, naturaleza, premium accesible.
   ============================================================ */

:root {
  /* ---- Marca / verdes bosque ---- */
  --forest-deep: #18302600;     /* placeholder, see below */
  --forest:      #21392E;       /* sidebar — pino profundo */
  --forest-2:    #1A2D24;       /* sidebar gradiente base */
  --pine:        #2F6249;       /* primario / acción */
  --pine-soft:   #3C7657;       /* hover primario */
  --sage:        #7E9A82;       /* verde apagado, textos suaves */
  --moss:        #5B7A60;

  /* ---- Tierra / acentos cálidos ---- */
  --clay:        #C2734A;       /* acento terracota */
  --clay-soft:   #D98A5E;
  --honey:       #D7A24A;       /* dorado cálido */

  /* ---- Neutros cálidos ---- */
  --sand:        #F2EEE4;       /* fondo de página */
  --linen:       #FAF7EF;       /* fondo alterno / inputs */
  --card:        #FFFEFB;       /* tarjetas */
  --ink:         #262720;       /* texto principal */
  --ink-2:       #4A4C42;       /* texto secundario */
  --muted:       #7C7E70;       /* texto terciario */
  --line:        #E7E1D4;       /* bordes suaves */
  --line-2:      #D9D2C2;

  /* ---- Estados (semáforo, en familia tierra) ---- */
  --ok:          #4E8B5C;       /* OK / éxito */
  --ok-bg:       #E7F0E6;
  --warn:        #C99227;       /* bajo / alerta */
  --warn-bg:     #F6EDD4;
  --crit:        #BD5239;       /* crítico / peligro */
  --crit-bg:     #F6E2DB;
  --info:        #3E6E8E;
  --info-bg:     #E2ECF1;

  /* ---- Tipografía ---- */
  --font-ui: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --font-display: "Spectral", Georgia, serif;

  /* ---- Radios ---- */
  --r-sm: 9px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;

  /* ---- Sombras (cálidas, suaves) ---- */
  --sh-sm: 0 1px 2px rgba(40,45,30,.05), 0 1px 3px rgba(40,45,30,.04);
  --sh-md: 0 4px 14px rgba(40,45,30,.07), 0 2px 6px rgba(40,45,30,.05);
  --sh-lg: 0 18px 50px rgba(30,45,35,.18), 0 6px 18px rgba(30,45,35,.10);

  --sidebar-w: 256px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  background: var(--sand);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--pine); color: #fff; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* subtle scrollbar */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--sage); background-clip: content-box; }

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

/* ---- Sidebar ---- */
.sidebar {
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(63,118,87,.30), transparent 60%),
    linear-gradient(180deg, var(--forest) 0%, var(--forest-2) 100%);
  color: #DCE7DD;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 8px 22px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.brand-logo {
  width: 76px; height: 76px;
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.25));
}
.brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.12;
  color: #fff;
  letter-spacing: .2px;
}
.brand-tag {
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--sage);
  margin-top: 3px;
}
.nav-group-label {
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(220,231,221,.45);
  padding: 16px 12px 7px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: #C8D6C9;
  font-size: 14.5px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,.10);
  color: #fff;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -16px; top: 8px; bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--honey);
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; opacity: .9; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--crit);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px; height: 20px;
  border-radius: 10px;
  display: grid; place-items: center;
  padding: 0 6px;
}
.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.09);
  display: flex; align-items: center; gap: 11px;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--clay), var(--honey));
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  flex: 0 0 auto;
}
.sidebar-foot .uname { font-size: 13.5px; font-weight: 600; color: #fff; }
.sidebar-foot .urole { font-size: 11.5px; color: var(--sage); }

/* ---- Main ---- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 20px 36px;
  position: sticky; top: 0; z-index: 20;
  background: rgba(242,238,228,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.page-title { font-family: var(--font-display); font-size: 27px; font-weight: 600; color: var(--ink); line-height: 1.1; white-space: nowrap; }
.page-head { flex: 0 0 auto; }

/* ---- Controles de menú móvil (ocultos en escritorio) ---- */
.hamburger, .drawer-close { display: none; }
.nav-scrim { display: none; }
.page-sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.topbar-spacer { flex: 1; }
.cloud-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 13px 7px 11px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: default;
  user-select: none;
}
.cloud-dot {
  width: 9px; height: 9px; border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 0 rgba(60,154,107,.5);
}
.cloud-dot.live { animation: cloudPulse 2s ease-out infinite; }
@keyframes cloudPulse {
  0%   { box-shadow: 0 0 0 0 rgba(60,154,107,.45); }
  70%  { box-shadow: 0 0 0 7px rgba(60,154,107,0); }
  100% { box-shadow: 0 0 0 0 rgba(60,154,107,0); }
}
.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  width: 280px;
  color: var(--muted);
}
.search input { border: none; outline: none; background: transparent; font-size: 14px; color: var(--ink); width: 100%; }
.search svg { width: 17px; height: 17px; flex: 0 0 auto; }

.content { padding: 30px 36px 60px; }

/* ============================================================
   COMPONENTES
   ============================================================ */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-sm);
  padding: 10px 17px;
  font-size: 14px; font-weight: 600;
  border: 1px solid transparent;
  transition: background .15s, box-shadow .15s, transform .05s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--pine); color: #fff; box-shadow: var(--sh-sm); }
.btn-primary:hover { background: var(--pine-soft); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--line-2); background: var(--linen); }
.btn-clay { background: var(--clay); color: #fff; }
.btn-clay:hover { background: var(--clay-soft); }
.btn-danger { background: transparent; color: var(--crit); border-color: transparent; }
.btn-danger:hover { background: var(--crit-bg); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: var(--r-sm); }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-pad { padding: 22px 24px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--sh-sm);
  position: relative;
  overflow: hidden;
}
.stat .stat-ico {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; margin-bottom: 16px;
}
.stat .stat-ico svg { width: 22px; height: 22px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 600; color: var(--ink);
  margin-top: 3px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-delta { font-size: 12.5px; font-weight: 600; margin-top: 9px; display: inline-flex; align-items: center; gap: 4px; }
.delta-up { color: var(--ok); }
.delta-down { color: var(--crit); }

/* Section header */
.section-head { display: flex; align-items: center; gap: 14px; margin: 30px 0 16px; }
.section-head h2 { font-family: var(--font-display); font-size: 21px; font-weight: 600; margin: 0; color: var(--ink); white-space: nowrap; flex: 0 0 auto; }
.section-head .sh-sub { font-size: 13px; color: var(--muted); white-space: nowrap; }
.card-head { margin-bottom: 16px; }
.card-head h2 { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin: 0; color: var(--ink); }
.card-head .ch-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.section-head .spacer { flex: 1; }

/* Badges / pills */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.2;
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge-ok   { background: var(--ok-bg);   color: #2F6B3C; }
.badge-ok   .dot { background: var(--ok); }
.badge-warn { background: var(--warn-bg); color: #8A6410; }
.badge-warn .dot { background: var(--warn); }
.badge-crit { background: var(--crit-bg); color: #9A3B26; }
.badge-crit .dot { background: var(--crit); }
.badge-neutral { background: var(--linen); color: var(--ink-2); border: 1px solid var(--line); }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 7px; font-size: 12px; font-weight: 500;
  background: var(--linen); color: var(--ink-2); border: 1px solid var(--line);
}

/* InfoTip — botón "?" de ayuda */
.infotip-btn {
  display: inline-grid; place-items: center; vertical-align: middle;
  width: 17px; height: 17px; margin-left: 6px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line-2);
  background: var(--linen); color: var(--muted);
  font-size: 11px; font-weight: 700; line-height: 1; font-family: var(--font-ui);
  transition: background .14s, color .14s, border-color .14s;
  flex: 0 0 auto;
}
.infotip-btn:hover { background: var(--pine); color: #fff; border-color: var(--pine); }
.infotip-btn:active { transform: translateY(1px); }

/* Tarjetas de indicador clickeables (abren su desglose) */
.stat.clickable { cursor: pointer; transition: box-shadow .15s, border-color .15s, transform .05s; }
.stat.clickable:hover { box-shadow: var(--sh-md); border-color: var(--line-2); }
.stat.clickable:hover .stat-more { opacity: 1; color: var(--pine); }
.stat.clickable:active { transform: translateY(1px); }
.stat.clickable:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }
.stat .stat-more { position: absolute; top: 14px; right: 14px; color: var(--muted); opacity: .45; transition: opacity .15s, color .15s; }

/* Lista de desglose dentro del modal de detalle */
.detail-intro { margin: 0 0 14px; font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }
.detail-list { display: flex; flex-direction: column; max-height: 52vh; overflow-y: auto; }
.detail-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 2px; border-bottom: 1px dashed var(--line); }
.detail-row:last-child { border-bottom: none; }
.dl-name { font-size: 14px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dl-sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.dl-val { font-size: 14px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; flex: 0 0 auto; }
.detail-empty { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.detail-foot { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 14px; font-weight: 700; font-size: 14.5px; color: var(--ink); }

/* Tables */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh-sm); }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); padding: 14px 18px; background: var(--linen);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink-2); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: var(--linen); }
.td-strong { color: var(--ink); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }

/* product cell */
.prod-cell { display: flex; align-items: center; gap: 12px; }
.prod-thumb {
  width: 42px; height: 42px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; overflow: hidden;
  background: var(--linen); border: 1px solid var(--line);
}
.prod-thumb svg { width: 22px; height: 22px; color: var(--sage); }
.prod-thumb.has-img { background: none; border-color: var(--line); }
.prod-thumb.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sup-avatar { overflow: hidden; }
.sup-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* selector de imagen */
.img-picker { display: flex; gap: 16px; align-items: center; }
.img-preview {
  width: 96px; height: 96px; flex: 0 0 auto;
  display: grid; place-items: center; overflow: hidden;
  background: var(--linen);
  border: 1.5px dashed var(--line-2);
  color: var(--sage);
}
.img-preview.rect { border-radius: var(--r-md); }
.img-preview.rounded { border-radius: var(--r-md); }
.img-preview.filled { border-style: solid; border-color: var(--line); }
.img-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.img-actions .btn.danger { color: var(--crit); }
.img-hint { font-size: 12px; color: var(--muted); }
.img-spin {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--pine);
  animation: imgspin .8s linear infinite;
}
@keyframes imgspin { to { transform: rotate(360deg); } }

/* row actions */
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; display: grid; place-items: center; color: var(--muted);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--linen); color: var(--ink); }
.icon-btn.danger:hover { background: var(--crit-bg); color: var(--crit); }
.icon-btn svg { width: 17px; height: 17px; }

/* Filters bar */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  transition: all .14s;
}
.chip:hover { border-color: var(--sage); }
.chip.active { background: var(--forest); color: #fff; border-color: var(--forest); }
.toolbar .spacer { flex: 1; }
.select {
  appearance: none; padding: 9px 34px 9px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--card); font-size: 13.5px; color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237C7E70' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(28,40,32,.42);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 24px;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card);
  border-radius: var(--r-xl);
  width: 100%; max-width: 640px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--sh-lg);
  animation: pop .2s cubic-bezier(.2,.9,.3,1.2);
}
.modal.wide { max-width: 820px; }
.modal.narrow { max-width: 440px; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; gap: 14px; padding: 24px 26px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; border-radius: var(--r-xl) var(--r-xl) 0 0; }
.modal-head h3 { font-family: var(--font-display); font-size: 21px; margin: 0; font-weight: 600; }
.modal-head p { font-size: 13px; color: var(--muted); margin: 3px 0 0; }
.modal-body { padding: 22px 26px; }
.modal-foot { padding: 16px 26px 22px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--card); }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.input, .textarea {
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 10px 13px; font-size: 14px; color: var(--ink); background: var(--linen);
  transition: border-color .14s, box-shadow .14s; outline: none; width: 100%;
}
.input:focus, .textarea:focus { border-color: var(--pine); box-shadow: 0 0 0 3px rgba(47,98,73,.13); background: #fff; }
.textarea { resize: vertical; min-height: 78px; }
.input-prefix { position: relative; }
.input-prefix .pfx { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.input-prefix .input { padding-left: 28px; }

/* Empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty svg { width: 46px; height: 46px; opacity: .4; margin-bottom: 12px; }

/* Progress bars (stock) */
.bar { height: 8px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 6px; }

/* mini list */
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 190px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bars .col .b { width: 100%; max-width: 38px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--pine-soft), var(--pine)); transition: height .5s cubic-bezier(.2,.8,.3,1); }
.bars .col .lbl { font-size: 11.5px; color: var(--muted); }

/* donut legend */
.legend { display: flex; flex-direction: column; gap: 12px; }
.legend .li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.legend .li .sw { width: 12px; height: 12px; border-radius: 4px; flex: 0 0 auto; }
.legend .li .nm { color: var(--ink-2); }
.legend .li .vl { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

/* toast */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--forest); color: #fff; padding: 12px 18px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; box-shadow: var(--sh-lg); display: flex; align-items: center; gap: 10px;
  animation: toastin .25s ease;
}
.toast svg { width: 18px; height: 18px; color: var(--honey); }
@keyframes toastin { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* helpers */
.flex { display: flex; }
.card-pad .flex.aic.gap8 { align-items: flex-start; line-height: 1.3; }
.card-pad .flex.aic.gap8 svg { margin-top: 2px; }
.between { justify-content: space-between; }
.aic { align-items: center; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.muted { color: var(--muted); }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }

@media (max-width: 1100px) {
  /* !important para ganarle a los grid-template puestos en estilos en línea */
  .stat-grid { grid-template-columns: repeat(2,1fr) !important; }
  .grid-2 { grid-template-columns: 1fr !important; }
  .grid-3 { grid-template-columns: 1fr !important; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }

  /* Sidebar como cajón deslizable (off-canvas) */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 270px; max-width: 84vw;
    z-index: 60;
    transform: translateX(-105%);
    transition: transform .26s cubic-bezier(.3,.8,.3,1);
    box-shadow: var(--sh-lg);
    height: 100vh; overflow-y: auto;
  }
  .drawer-open .sidebar { transform: translateX(0); }

  /* Fondo oscuro al abrir el menú */
  .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(20,30,24,.45);
    opacity: 0; pointer-events: none;
    transition: opacity .26s ease;
  }
  .drawer-open .nav-scrim { opacity: 1; pointer-events: auto; }

  /* Botón hamburguesa en la barra superior */
  .hamburger {
    display: grid; place-items: center;
    width: 42px; height: 42px; flex: 0 0 auto;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--card); color: var(--ink);
  }
  .hamburger svg { width: 22px; height: 22px; }

  /* Botón cerrar dentro del cajón */
  .drawer-close {
    display: grid; place-items: center;
    position: absolute; top: 14px; right: 14px;
    width: 36px; height: 36px;
    border: none; border-radius: var(--r-sm);
    background: rgba(255,255,255,.10); color: #fff;
  }

  /* Barra superior compacta */
  .topbar { padding: 14px 16px; gap: 12px; }
  .page-title { font-size: 21px; white-space: normal; }
  .page-sub { display: none; }
  .topbar .search { display: none; }
  .cloud-pill { padding: 7px 11px; }
  .cloud-label { display: none; }

  /* Contenido más ajustado */
  .content { padding: 18px 16px 60px !important; }
  .form-grid { grid-template-columns: 1fr; }

  /* Encabezados de sección: que se acomoden en varias líneas (no fuercen ancho) */
  .section-head { flex-wrap: wrap; gap: 8px 10px; }
  .section-head h2 { white-space: normal; }
  .section-head .sh-sub { white-space: normal; }
  .section-head .spacer { display: none; }
  .toolbar .search { width: 100% !important; }

  /* Tablas → tarjetas apiladas (cada fila es una tarjeta, sin scroll horizontal) */
  .table-wrap { overflow: visible; border: none; background: transparent; box-shadow: none; border-radius: 0; }
  table.tbl { min-width: 0; }
  table.tbl thead { display: none; }
  table.tbl, table.tbl tbody, table.tbl tr, table.tbl td { display: block; width: 100%; }
  table.tbl tr {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
    box-shadow: var(--sh-sm); padding: 4px 16px 6px; margin-bottom: 12px;
  }
  table.tbl td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 11px 0; border-bottom: 1px solid var(--line);
    text-align: right; white-space: normal;
  }
  table.tbl tr td:last-child { border-bottom: none; }
  /* etiqueta de la columna a la izquierda de cada dato */
  table.tbl td::before {
    content: attr(data-label);
    font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); text-align: left; flex: 0 0 auto; white-space: nowrap;
  }
  /* primera celda (producto): ancho completo, como encabezado de la tarjeta, sin etiqueta */
  table.tbl td:first-child { display: block; text-align: left; padding: 14px 0 12px; }
  table.tbl td:first-child::before { display: none; }
  /* fila de "sin resultados" (una sola celda) ocupa todo el ancho */
  table.tbl td[colspan] { display: block; text-align: center; border-bottom: none; }
  table.tbl td[colspan]::before { display: none; }
}

@media (max-width: 520px) {
  /* !important para ganarle a repeat(3,1fr) puesto en estilos en línea (costos/compras) */
  .stat-grid { grid-template-columns: 1fr !important; }
  /* el modal usa todo el ancho disponible sin pasarse de la pantalla */
  .modal-overlay { padding: 12px; }
  .modal, .modal.wide, .modal.narrow { width: 100%; }
  .topbar { flex-wrap: wrap; }
  .page-title { font-size: 19px; }
}

/* lista de precios para el cliente */
.pricelist { display: flex; flex-direction: column; }
.pl-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.pl-row:last-child { border-bottom: none; }
.pl-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pl-name { font-weight: 600; font-size: 14.5px; color: var(--ink); }
.pl-price {
  font-family: var(--font-display);
  font-size: 21px; font-weight: 700; color: var(--pine);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* impresión: solo la lista de precios */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .toast-wrap, .tweaks-launcher, .modal-head .icon-btn,
  .modal-foot, .modal-body > .search { display: none !important; }
  .modal-overlay { position: static; background: none; padding: 0; display: block; }
  .modal, .modal.wide { box-shadow: none; max-height: none; width: 100%; max-width: 100%; }
  .pl-row { break-inside: avoid; }
  .pl-price { color: #1f4636; }
}
