:root {
  color-scheme: light;
  /* Shaw's brand (logo-sampled) */
  --brand: #eb1c23;        /* fills: buttons, active tab (white text on top) */
  --brand-ink: #c4151b;    /* red as text/links on light surfaces */
  --brand-dark: #c4151b;   /* button hover */
  --tint: #fceded;
  --tint-2: #fff2f2;
  --ring: #fcd9da;
  /* ink + neutrals */
  --ink: #1c1917;
  --muted: #6b7280;
  --line: #e7e5e4;
  --surface: #ffffff;      /* page */
  --card: #ffffff;
  --surface-2: #faf9f9;
  --hover-shadow: 0 2px 10px rgba(235, 28, 35, .08);
  /* signals */
  --neg: #b91c1c;          /* badge fill */
  --neg-text: #b91c1c;     /* negative stock text */
  --focus: #c4151b;
}

:root[data-theme="oscuro"] {
  color-scheme: dark;
  --brand: #eb1c23;
  --brand-ink: #f4646a;
  --brand-dark: #f4646a;
  --tint: #3d1517;
  --tint-2: #2b1213;
  --ring: #57181b;
  --ink: #ede8e6;
  --muted: #a8a29e;
  --line: #322c29;
  --surface: #141210;
  --card: #1d1a17;
  --surface-2: #211e1b;
  --hover-shadow: 0 2px 12px rgba(0, 0, 0, .5);
  --neg-text: #f88080;
  --focus: #f4646a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="claro"]) {
    color-scheme: dark;
    --brand-ink: #f4646a;
    --brand-dark: #f4646a;
    --tint: #3d1517;
    --tint-2: #2b1213;
    --ring: #57181b;
    --ink: #ede8e6;
    --muted: #a8a29e;
    --line: #322c29;
    --surface: #141210;
    --card: #1d1a17;
    --surface-2: #211e1b;
    --hover-shadow: 0 2px 12px rgba(0, 0, 0, .5);
    --neg-text: #f88080;
    --focus: #f4646a;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  margin: 0;
  color: var(--ink);
  background: var(--surface);
}

::selection { background: var(--tint); color: var(--brand-ink); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
nav .brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  color: inherit;
  text-decoration: none;
}
nav .brand img { height: 2rem; width: auto; display: block; }
nav a { color: inherit; text-decoration: none; padding: .25rem 0; }
nav a:hover { color: var(--brand-ink); }
nav .spacer { flex: 1; }
nav .user { color: var(--muted); }
nav button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: .375rem;
  padding: .3rem .7rem;
  cursor: pointer;
  color: var(--ink);
  font-size: .85rem;
}
nav button:hover { border-color: var(--brand-ink); color: var(--brand-ink); }

main { padding: 1rem; max-width: 75rem; margin: 0 auto; }

h1 { font-size: 1.25rem; margin: .25rem 0 .9rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: .75rem;
}
.card {
  border: 1px solid var(--line);
  border-radius: .5rem;
  padding: .75rem 1rem;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
.card:hover {
  border-color: var(--brand);
  box-shadow: var(--hover-shadow);
}
.card h2 { margin: 0 0 .25rem; font-size: 1.05rem; }
.card p { margin: .15rem 0; }
.muted { color: var(--muted); font-size: .85rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-bottom: .75rem;
}
.toolbar input[type="search"],
.toolbar select {
  font-size: 1rem;              /* 16px: no iOS focus zoom */
  padding: .4rem .6rem;
  border: 1px solid var(--line);
  border-radius: .375rem;
  background: var(--card);
  color: var(--ink);
}
.toolbar input[type="search"] { flex: 1 1 12rem; min-width: 0; }
.toolbar input:focus-visible,
.toolbar select:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}
.toolbar button {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  border: none;
  border-radius: .375rem;
  padding: .45rem .9rem;
  cursor: pointer;
  transition: filter 150ms ease-out;
}
.toolbar button:hover { filter: brightness(.88); }
.toolbar label { display: flex; align-items: center; gap: .3rem; }
.toolbar input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--brand); }

.tabs {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  margin-bottom: .6rem;
}
.tabs a {
  padding: .25rem .65rem;
  border: 1px solid var(--line);
  border-radius: .3rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 150ms ease-out, background 150ms ease-out;
}
.tabs a:hover { border-color: var(--brand); color: var(--brand-ink); }
.tabs a.cur {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  font-weight: 600;
}

.coltoggles { margin: -.25rem 0 .75rem; }
.coltoggle {
  color: inherit;
  text-decoration: none;
  padding: .1rem .4rem;
  border: 1px solid var(--line);
  border-radius: .3rem;
}
.coltoggle:hover { border-color: var(--brand); color: var(--brand-ink); }

.tablewrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: .92rem;
  min-width: 44rem;
  font-variant-numeric: tabular-nums;
}
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
th { white-space: nowrap; font-size: .85rem; color: var(--muted); }
th a.sortable { color: inherit; text-decoration: none; }
th a.sortable:hover { color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; }
th .arrow { color: var(--brand-ink); font-size: .7em; margin-left: .15rem; }
td.num, th.num { text-align: right; }
td .codigo {
  color: var(--muted);
  margin-right: .4rem;
  font-size: .85em;
  font-variant-numeric: tabular-nums;
}
td a.cell { color: inherit; text-decoration: none; }
td a.cell:hover { color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; }
.badge {
  background: var(--neg);
  color: #fff;
  border-radius: .3rem;
  padding: 0 .35rem;
  font-size: .78rem;
  margin-left: .35rem;
}
tr.negativo td.stock { color: var(--neg-text); font-weight: 700; }

.pager { margin: .75rem 0; display: flex; gap: .35rem; flex-wrap: wrap; }
.pager a, .pager span {
  padding: .15rem .5rem;
  border: 1px solid var(--line);
  border-radius: .3rem;
}
.pager a { color: inherit; text-decoration: none; }
.pager a:hover { border-color: var(--brand); color: var(--brand-ink); }
.pager .cur { background: var(--brand); color: #fff; border-color: var(--brand); }

@media (max-width: 40rem) {
  main { padding: .75rem; }
  nav { padding: .5rem .75rem; }
  h1 { font-size: 1.15rem; }
}
