:root {
  --ink: #2a1f17; --muted: #7a6a5a; --line: #e8dfcf; --line-strong: #d6c7ae;
  --canvas: #f4eee2; --surface: #fffdf8;
  --wood-950: #24180f; --wood-900: #33231a; --wood-800: #4a3222; --wood-600: #8a5a35; --wood-100: #f3e7d6;
  --pasture: #4f6f35; --pasture-soft: #e6eed8; --ochre: #c88a14; --ochre-soft: #fbefcf; --tag: #f2c230;
  --terra: #b5542d; --terra-dark: #93401f; --terra-soft: #f8e2d7; --red: #a33b2b;
  --blue: #3f6b84; --blue-soft: #e3edf2;
  --accent: var(--terra); --accent-dark: var(--terra-dark);
  --slab: "Rockwell", "Roboto Slab", "Zilla Slab", "Georgia", serif;
  --radius: 10px;
  --shadow: 0 18px 44px rgba(52,33,18,.16);
  --shadow-soft: 0 2px 0 rgba(90,60,30,.06), 0 8px 20px rgba(90,60,30,.06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink); font-size: 15px; line-height: 1.45; padding-top: 30px;
  background: var(--canvas) radial-gradient(rgba(138,90,53,.07) 1px, transparent 1.2px) 0 0 / 14px 14px;
}
body.has-rubro-bar { padding-bottom: 72px; }
body.has-rubro-bar .ps4-home { bottom: 58px; }
body.has-rubro-bar .ps4-stage { bottom: 52px; }
body.has-rubro-bar .ps4-hints { bottom: 10px; }
body.has-rubro-bar #appShell { padding-bottom: 72px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--slab); font-weight: 700; letter-spacing: -.01em; }

.demo-strip {
  position: fixed; inset: 0 0 auto 0; height: 30px; z-index: 90;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--tag); color: var(--wood-950); font-size: .76rem; font-weight: 700;
}
.demo-strip .tag {
  padding: 2px 8px; border-radius: 4px; background: var(--wood-950); color: var(--tag);
  font-size: .66rem; font-weight: 900; letter-spacing: .12em;
}
.demo-strip .txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-strip button {
  padding: 3px 11px; border: 1.5px solid var(--wood-950); border-radius: 4px;
  background: transparent; color: var(--wood-950); font-size: .72rem; font-weight: 800;
}

/* ---------- PS4 / hub / home ---------- */
.ps4-home {
  position: fixed; inset: 0; z-index: 80; overflow: hidden; color: var(--ink);
  background:
    radial-gradient(880px 380px at 88% 100%, rgba(200,138,20,.16), transparent 62%),
    radial-gradient(720px 340px at 0% 0%, rgba(181,84,45,.1), transparent 58%),
    var(--canvas);
}
.ps4-home canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ps4-top, .ps4-stage, .ps4-hints { position: relative; z-index: 1; }
.ps4-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 32px 0; }
.ps4-user { display: flex; align-items: center; gap: 12px; min-width: 0; font-size: 1.02rem; font-weight: 700; color: var(--wood-950); }
.ps4-user-meta { display: grid; min-width: 0; }
.ps4-user-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps4-user-meta small { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.ps4-avatar {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--tag); color: var(--wood-950); border: 3px solid #fff3c9; font-weight: 800;
}
.ps4-clock { flex: 0 0 auto; text-align: right; color: var(--wood-900); }
.ps4-clock strong { display: block; font-family: var(--slab); font-size: 1.55rem; font-weight: 700; }
.ps4-clock span { display: block; color: var(--muted); font-size: .84rem; text-transform: capitalize; white-space: nowrap; }
.ps4-stage {
  position: absolute; left: 0; right: 0; top: 88px; bottom: 64px;
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 8px; overflow: hidden;
}
.hub-brand, .home-brand-block { text-align: center; padding: 0 24px 2px; flex: 0 0 auto; }
.hub-kicker { margin: 0; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.hub-brand h1, .home-brand-block h1 { margin: 4px 0 2px; font-size: clamp(1.45rem, 4.5vw, 2.1rem); color: var(--wood-900); }
.hub-sub { margin: 0; color: var(--muted); font-size: .92rem; }
.home-bar {
  display: flex; align-items: center; gap: 12px; padding: 0 28px; flex: 0 0 auto;
}
.home-bar strong {
  font-family: var(--slab); font-size: 1.05rem; letter-spacing: .04em; text-transform: uppercase; color: var(--wood-900);
  flex: 1; text-align: center;
}
.sec-count, #secModCount { color: var(--muted); font-weight: 800; font-size: .9rem; }
.pill-back, .pill-x {
  border: 1.5px solid var(--wood-800); background: transparent; color: var(--wood-800);
  border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: .82rem;
}
.pill-x { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; }
.sec-head {
  display: flex; align-items: center; gap: 10px; padding: 4px 28px 0; flex: 0 0 auto;
}
.sec-mark {
  width: 18px; height: 18px; border-radius: 4px; background: var(--accent); flex: 0 0 auto;
}
.sec-head h3 {
  margin: 0; flex: 1; font-size: 1.05rem; letter-spacing: .08em; text-transform: uppercase; color: var(--wood-900);
}
.ps4-row-wrap {
  width: 100%; min-width: 0; min-height: 0; flex: 1 1 auto;
  display: flex; align-items: flex-start; overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; overscroll-behavior-x: contain; scrollbar-width: none;
}
.ps4-row-wrap::-webkit-scrollbar { height: 0; }
.ps4-row {
  display: grid; width: max-content; flex: 0 0 auto; margin: 0; justify-content: start;
  padding: 20px 16px 16px; gap: 14px; grid-auto-flow: column; grid-template-rows: auto;
}
.hub-row { gap: 16px; padding-top: 12px; }
.ps4-tile {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end;
  width: var(--tile, 148px); height: var(--tile, 148px); padding: 14px;
  border: 0; border-radius: 18px; color: #fff; text-align: left; overflow: hidden;
  box-shadow: 0 8px 18px rgba(52,33,18,.18); transition: transform .2s ease, box-shadow .2s ease;
  position: relative;
}
.ps4-tile .ico {
  position: absolute; top: 14px; left: 14px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(255,255,255,.22); font-size: .95rem; font-weight: 900;
}
.ps4-tile b {
  display: block; max-width: 100%; font-family: var(--slab); font-size: var(--face, 1.05rem);
  font-weight: 800; line-height: 1.1; letter-spacing: .02em; text-transform: uppercase;
}
.ps4-tile small { display: block; margin-top: 4px; opacity: .9; font-size: .78rem; font-weight: 700; }
.ps4-tile.terra { background: linear-gradient(155deg, #d46a3c, var(--terra-dark)); }
.ps4-tile.pasture { background: linear-gradient(155deg, #6d8f4e, #3d5628); }
.ps4-tile.wood { background: linear-gradient(155deg, #6a4630, var(--wood-900)); color: #f4e9d8; }
.ps4-tile.ochre { background: linear-gradient(155deg, var(--tag), var(--ochre)); color: var(--wood-950); }
.ps4-tile.blue { background: linear-gradient(155deg, #5d8aa3, var(--blue)); }
.ps4-tile.leather { background: linear-gradient(155deg, var(--wood-600), var(--wood-800)); }
.ps4-tile.avocado { background: linear-gradient(155deg, #7aa33a, #3f5c1e); }
.ps4-tile.cheese { background: linear-gradient(155deg, #e8c15a, #b8841a); color: var(--wood-950); }
.ps4-tile.berry { background: linear-gradient(155deg, #6b4a9a, #3a2560); }
.ps4-tile.veg { background: linear-gradient(155deg, #5fa87a, #2f6b48); }
.ps4-tile.onion { background: linear-gradient(155deg, #c9845a, #7a4028); }
.ps4-tile.potato { background: linear-gradient(155deg, #c4a06a, #7a5a30); }
.ps4-tile.on {
  transform: scale(1.08);
  box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--wood-950), 0 14px 28px rgba(52,33,18,.28);
  z-index: 1;
}
.ps4-caption { display: block; width: 100%; flex: 0 0 auto; margin-top: auto; text-align: center; padding: 8px 28px 4px; }
.ps4-caption p, .ps4-caption h2 { margin: 0; }
#hubKicker, #homeKicker, #secKicker { color: var(--accent); font-size: .74rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
#hubTitle, #homeTitle, #secTitle { margin: 4px 0; font-size: 1.85rem; color: var(--wood-900); }
#hubDesc, #homeDesc, #secDesc { color: var(--muted); font-size: .95rem; }
#hubStats, #homeStats, #secStats { margin-top: 6px; color: var(--accent-dark); font-weight: 800; }
.ps4-hints {
  position: absolute; left: 32px; bottom: 22px; display: flex; gap: 22px;
  color: var(--wood-800); font-size: .92rem; font-weight: 700;
}
.ps4-hints i {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-right: 6px;
  padding: 0 6px; border-radius: 11px; border: 1.5px solid var(--wood-800); font-style: normal; font-size: .68rem;
}
.ps4-hints .psx { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- switcher de apps / rubros (barra inferior) ---------- */
.rubro-bar {
  position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 95;
  display: flex; gap: 6px; padding: 7px; overflow-x: auto; scrollbar-width: none;
  background: rgba(36, 24, 15, .92); border-radius: 999px;
  box-shadow: 0 10px 28px rgba(36, 24, 15, .35);
  -webkit-overflow-scrolling: touch;
}
.rubro-bar::-webkit-scrollbar { height: 0; }
.rubro-pill {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  border: 0; border-radius: 999px; padding: 8px 12px;
  background: transparent; color: #e8dcc8; font-weight: 800; font-size: .78rem;
  white-space: nowrap; transition: .15s;
}
.rubro-pill:hover { background: rgba(255,255,255,.08); color: #fff; }
.rubro-pill.on {
  background: #fff; color: var(--wood-950);
  box-shadow: 0 0 0 2px var(--accent);
}
.rubro-pill-ico {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.14); font-size: .72rem; font-weight: 900;
}
.rubro-pill.on .rubro-pill-ico { background: var(--accent); color: #fff; }
.rubro-pill.avocado.on { box-shadow: 0 0 0 2px #4f6f35; }
.rubro-pill.cheese.on { box-shadow: 0 0 0 2px #b8841a; }
.rubro-pill.berry.on { box-shadow: 0 0 0 2px #6b4a9a; }
.rubro-pill.veg.on { box-shadow: 0 0 0 2px #2f6b48; }
.rubro-pill.onion.on { box-shadow: 0 0 0 2px #a85a32; }
.rubro-pill.potato.on { box-shadow: 0 0 0 2px #8a6a30; }

/* ---------- app shell ---------- */
.ranch-header {
  position: sticky; top: 30px; z-index: 30; color: #f4e9d8;
  background: var(--wood-950) repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 2px, transparent 2px 9px);
  border-bottom: 4px solid var(--accent); box-shadow: 0 6px 18px rgba(36,24,15,.25);
}
.rh-top { display: flex; align-items: center; gap: 16px; padding: 10px 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 11px; flex: 0 0 auto; border: 0; background: transparent; padding: 0; color: inherit; text-align: left; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  background: var(--tag); color: var(--wood-950); border: 3px solid #fff3c9; font-family: var(--slab); font-weight: 800;
}
.brand strong { display: block; font-family: var(--slab); font-size: 1.05rem; letter-spacing: .02em; }
.brand span { display: block; color: #cdb99c; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.group-tabs { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.group-tab {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px 18px; border: 0;
  border-radius: 8px 8px 0 0; background: transparent; color: #d9c6a8;
  font-family: var(--slab); font-weight: 700; font-size: .9rem; position: relative; top: 8px; white-space: nowrap;
}
.group-tab.active { color: var(--wood-950); background: var(--canvas); }
.top-actions { margin-left: auto; }
.sub-tabs {
  display: flex; gap: 2px; padding: 0 18px; background: var(--canvas);
  border-bottom: 1px solid var(--line-strong); overflow-x: auto; scrollbar-width: thin;
}
.sub-tab {
  display: flex; align-items: center; gap: 7px; padding: 12px 14px 10px; border: 0;
  border-bottom: 3px solid transparent; background: transparent; color: var(--muted);
  font-weight: 700; font-size: .87rem; white-space: nowrap;
}
.sub-tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); }

.page-title-row {
  max-width: 1100px; margin: 0 auto; display: flex; align-items: flex-end; gap: 16px;
  padding: 18px 18px 0; flex-wrap: wrap;
}
.page-heading { margin-right: auto; min-width: 0; }
.page-heading p {
  margin: 0 0 3px; color: var(--accent); font-size: .7rem; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase;
}
.page-heading h1 { margin: 0; font-size: 1.55rem; color: var(--wood-900); }

.button {
  min-height: 40px; padding: 8px 15px; border: 1.5px solid transparent; border-radius: 8px;
  font-weight: 750; transition: .14s; display: inline-flex; align-items: center; gap: 7px;
  justify-content: center; text-decoration: none; white-space: nowrap;
}
.button.primary { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-dark); }
.button.primary:hover { filter: brightness(.96); }
.button.secondary { background: var(--surface); color: var(--wood-800); border-color: var(--line-strong); }
.button.glass { background: rgba(255,255,255,.08); color: #f4e9d8; border-color: rgba(255,255,255,.25); }
.button.small { min-height: 32px; padding: 5px 10px; font-size: .8rem; }

main { max-width: 1100px; margin: 0 auto; padding: 16px 18px 40px; }
.view { display: grid; gap: 16px; }
.app-foot {
  text-align: center; padding: 8px 16px 28px; color: var(--muted); font-size: .78rem; font-weight: 700;
}

.metric-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.metric {
  position: relative; padding: 12px 14px; border: 1px solid var(--line); border-left: 6px solid var(--accent);
  border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-soft); text-align: left;
}
.metric > span {
  display: block; color: var(--muted); font-size: .68rem; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase;
}
.metric > strong { display: block; margin-top: 4px; font-family: var(--slab); font-size: 1.35rem; color: var(--wood-900); }
.metric > small { display: block; margin-top: 2px; color: var(--muted); font-size: .72rem; }
.metric.alert { border-left-color: var(--terra); background: linear-gradient(90deg, var(--terra-soft), var(--surface) 60%); }
.metric.good { border-left-color: var(--pasture); background: linear-gradient(90deg, var(--pasture-soft), var(--surface) 60%); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-soft); overflow: hidden; min-width: 0;
}
.panel-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 14px 16px 10px; flex-wrap: wrap;
}
.panel-head h2 { margin: 2px 0 0; font-size: 1.05rem; color: var(--wood-900); }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: .8rem; max-width: 640px; }
.panel-body { padding: 0 16px 16px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th {
  font-size: .72rem; color: var(--muted); font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { font-size: .88rem; padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #faf6ee; }
.tag-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 800;
  background: var(--wood-100); color: var(--wood-800);
}
.tag-pill.ok { background: var(--pasture-soft); color: var(--pasture); }
.tag-pill.warn { background: var(--ochre-soft); color: #8a5a10; }
.tag-pill.bad { background: var(--terra-soft); color: var(--terra-dark); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.mini-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff;
}
.mini-card strong { display: block; font-family: var(--slab); font-size: 1rem; }
.mini-card span { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.mini-card .bar { height: 5px; background: var(--line); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.mini-card .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 100; max-width: 320px;
  background: var(--wood-950); color: #fff; padding: 12px 14px; border-radius: 10px;
  font-size: .88rem; font-weight: 700; box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  .ps4-top { padding: 16px 16px 0; }
  .ps4-clock strong { font-size: 1.15rem; }
  .ps4-stage { top: 74px; bottom: 56px; }
  #hubTitle, #homeTitle, #secTitle { font-size: 1.35rem; }
  .ps4-hints { left: 14px; right: 14px; bottom: 12px; gap: 14px; font-size: .82rem; }
  .hub-brand h1 { font-size: 1.55rem; }
  .ps4-tile { --tile: 128px; border-radius: 16px; }
  .group-tabs { order: 3; width: 100%; }
  .page-heading h1 { font-size: 1.3rem; }
}
