/* Adega Corvelle · ERP
   Sobrio y denso en datos. Una sola concesión de marca: los títulos y cifras grandes en Newsreader. */

:root {
  --bg: #F3F5F2;
  --surface: #FFFFFF;
  --surface-2: #F8FAF7;
  --ink: #18241F;
  --ink-2: #44524B;
  --muted: #6B7871;
  --line: #DFE5DF;
  --line-2: #EBEFEA;
  --side: #17241E;
  --side-ink: #C9D4CD;
  --side-mute: #82948A;
  --side-hover: #22332B;
  --accent: #2F5D46;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3EEE7;
  --gold: #B8871C;
  --gold-soft: #F6EED8;
  --ok: #1F7A4D;
  --ok-soft: #E1F1E7;
  --warn: #9A6A12;
  --warn-soft: #FBF0D9;
  --bad: #B4432E;
  --bad-soft: #F9E4DF;
  --info: #2F6E99;
  --info-soft: #E2EDF5;
  /* serie categórica validada (orden fijo) */
  --c1: #1F8457; --c2: #B8871C; --c3: #2F78B0; --c4: #B4523A; --c5: #7E5BB5; --c6: #7E8F1E;
  --grid: #E7ECE6;
  --shadow: 0 1px 2px rgba(23, 36, 30, .06), 0 4px 16px rgba(23, 36, 30, .04);
  --radius: 10px;
  --radius-s: 6px;
  --display: "Newsreader", Georgia, serif;
  --text: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101814; --surface: #16211C; --surface-2: #1B2721; --ink: #E6ECE8; --ink-2: #BAC6BF; --muted: #8A9A91;
    --line: #2A3830; --line-2: #222F28; --side: #0B120E; --side-hover: #16211C; --accent: #6FB38E; --accent-ink: #0B120E;
    --accent-soft: #1E3328; --gold: #D9AB45; --gold-soft: #2E2716; --ok: #5FBF8B; --ok-soft: #173126; --warn: #E0B04F; --warn-soft: #2F2615;
    --bad: #E27B66; --bad-soft: #3A1E19; --info: #6CA9D6; --info-soft: #172936; --grid: #24312A;
    --c1: #3FAF7A; --c2: #D4A23A; --c3: #5C9DD6; --c4: #D9775E; --c5: #A387D9; --c6: #A2B444;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101814; --surface: #16211C; --surface-2: #1B2721; --ink: #E6ECE8; --ink-2: #BAC6BF; --muted: #8A9A91;
  --line: #2A3830; --line-2: #222F28; --side: #0B120E; --side-hover: #16211C; --accent: #6FB38E; --accent-ink: #0B120E;
  --accent-soft: #1E3328; --gold: #D9AB45; --gold-soft: #2E2716; --ok: #5FBF8B; --ok-soft: #173126; --warn: #E0B04F; --warn-soft: #2F2615;
  --bad: #E27B66; --bad-soft: #3A1E19; --info: #6CA9D6; --info-soft: #172936; --grid: #24312A;
  --c1: #3FAF7A; --c2: #D4A23A; --c3: #5C9DD6; --c4: #D9775E; --c5: #A387D9; --c6: #A2B444;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--text); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg); font-feature-settings: "tnum" 1, "lnum" 1, "cv11" 1; }
a { color: inherit; text-decoration: none; }
a.link, .prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── estructura */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: #2a3a32 transparent; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #F1F4EF; }
.brand svg { width: 30px; height: 30px; }
.brand b { font-family: var(--display); font-size: 21px; font-weight: 500; letter-spacing: .01em; display: block; line-height: 1; }
.brand small { color: var(--side-mute); font-size: 11.5px; }
.nav { padding: 6px 10px 20px; flex: 1; }
.nav h6 { margin: 16px 10px 6px; font-size: 11.5px; font-weight: 600; color: var(--side-mute); letter-spacing: .02em; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--side-ink); font-size: 13.5px; }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a.on { background: #2B4337; color: #fff; }
.nav a.on svg { color: #E6C766; }
.nav a .count { margin-left: auto; font-size: 11px; background: #8C3A2A; color: #fff; border-radius: 9px; padding: 0 6px; line-height: 17px; }
.side-foot { padding: 12px 18px 16px; border-top: 1px solid #23332B; font-size: 12px; color: var(--side-mute); }
.side-foot a { color: var(--side-ink); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.search { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; color: var(--muted); cursor: text; }
.search span { flex: 1 1 auto; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search kbd { flex: none; white-space: nowrap; margin-left: auto; font: 11px var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--muted); }
.top .spacer { flex: 1; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface); border-color: var(--line); }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--bg); }
.who { display: flex; align-items: center; gap: 10px; padding-left: 6px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 12.5px; }
.who small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.2; }
.who b { font-weight: 600; font-size: 13px; line-height: 1.2; }
.menu-toggle { display: none; }

.page { padding: 26px 28px 60px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--display); font-weight: 500; font-size: 34px; line-height: 1.05; margin: 0; letter-spacing: -.005em; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a:hover { color: var(--ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ─── piezas */
.grid { display: grid; gap: 16px; }
.grid > *, .stack > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; }
.span2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt { margin-top: 16px; } .mt2 { margin-top: 24px; } .mb { margin-bottom: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 0; }
.card > header h2, .card > header h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card > header .sub { color: var(--muted); font-size: 12.5px; }
.card .body { padding: 14px 18px 18px; }
.card .body.flush { padding: 8px 0 4px; }
.card.pad { padding: 18px; }
.card footer { border-top: 1px solid var(--line-2); padding: 10px 18px; font-size: 12.5px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-family: var(--display); font-size: 32px; font-weight: 500; line-height: 1.1; margin-top: 6px; letter-spacing: -.01em; }
.kpi .value small { font-family: var(--text); font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.kpi .delta { font-size: 12.5px; margin-top: 4px; color: var(--muted); }
.kpi .delta.up { color: var(--ok); } .kpi .delta.down { color: var(--bad); }
.kpi canvas, .kpi svg.spark { display: block; margin-top: 8px; }

table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t tr.clickable { cursor: pointer; }
table.t .num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t td:first-child, table.t th:first-child { padding-left: 18px; }
table.t td:last-child, table.t th:last-child { padding-right: 18px; }
table.t tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.table-wrap, .card > .body.flush { overflow-x: auto; }
.table-wrap.tall { max-height: 560px; overflow-y: auto; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 20px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; line-height: 18px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.gold { background: var(--gold-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 500; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button { padding: 9px 14px; font-size: 13.5px; color: var(--muted); border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs a.on, .tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a, .seg button { padding: 6px 12px; font-size: 12.5px; color: var(--muted); border: 0; background: none; cursor: pointer; border-right: 1px solid var(--line); }
.seg a:last-child, .seg button:last-child { border-right: 0; }
.seg .on { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

/* formularios */
.form { display: grid; gap: 14px; }
.form .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
label.f { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
label.f > .input, label.f > select, label.f > textarea, label.f > input[type=file] { display: block; margin-top: 5px; }
label.f .hint { font-weight: 400; color: var(--muted); }
.input, select.input, textarea.input { height: 38px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 0 11px; font-size: 14px; width: 100%; }
textarea.input { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
.input.big { height: 56px; font-size: 26px; font-family: var(--display); font-weight: 500; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input { height: 34px; width: auto; min-width: 140px; font-size: 13px; }
.errors { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.flash { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90; background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 8px 30px rgba(0,0,0,.2); display: flex; gap: 10px; align-items: center; animation: flash-in .25s ease-out; }
@keyframes flash-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* listas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 18px; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--line-2); color: var(--ink-2); }
.list .ic.bad { background: var(--bad-soft); color: var(--bad); }
.list .ic.warn { background: var(--warn-soft); color: var(--warn); }
.list .ic.ok { background: var(--ok-soft); color: var(--ok); }
.list .ic.info { background: var(--info-soft); color: var(--info); }
.list .ic svg { width: 16px; height: 16px; }
.list b { font-weight: 600; font-size: 13.5px; }
.list p { margin: 1px 0 0; color: var(--muted); font-size: 12.5px; }
.list .end { margin-left: auto; text-align: right; flex: none; font-size: 12.5px; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 0; font-size: 13px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 500; }

.meter { height: 8px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.meter.gold i { background: var(--gold); } .meter.bad i { background: var(--bad); } .meter.warn i { background: var(--warn); }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* gráficos */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .grid line { stroke: var(--grid); }
.chart .baseline { stroke: var(--line); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--ink-2); margin: 0 0 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-legend i.line { height: 3px; border-radius: 2px; width: 14px; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12px; padding: 8px 10px; border-radius: 8px; white-space: nowrap; z-index: 5; transform: translate(-50%, -100%); margin-top: -10px; box-shadow: 0 6px 20px rgba(0,0,0,.18); opacity: 0; transition: opacity .1s; }
.tip.on { opacity: 1; }
.tip b { font-weight: 600; }
.tip .r { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tip .r i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* paneles laterales y modales */
.drawer-back { position: fixed; inset: 0; background: rgba(10, 18, 14, .35); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-back.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface); z-index: 61; transform: translateX(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.drawer.on { transform: none; }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer header h3 { margin: 0; font-size: 15px; }
.drawer .scroll { flex: 1; overflow-y: auto; }

.cmdk { position: fixed; inset: 0; z-index: 80; display: none; place-items: start center; padding-top: 12vh; background: rgba(10, 18, 14, .4); }
.cmdk.on { display: grid; }
.cmdk .box { width: min(640px, 92vw); background: var(--surface); border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; }
.cmdk input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 16px 18px; font-size: 16px; background: transparent; outline: none; }
.cmdk .results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.cmdk .results a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 8px; font-size: 13.5px; }
.cmdk .results a.sel, .cmdk .results a:hover { background: var(--accent-soft); }
.cmdk .results small { color: var(--muted); margin-left: auto; }
.cmdk .group { font-size: 11.5px; color: var(--muted); padding: 10px 12px 4px; }

/* asistente */
.assist .msgs { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.assist .m { max-width: 92%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; }
.assist .m.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.assist .m.bot { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.assist .m.bot table { font-size: 12.5px; border-collapse: collapse; margin-top: 6px; width: 100%; }
.assist .m.bot td { padding: 3px 6px 3px 0; border-bottom: 1px solid var(--line-2); }
.assist .m.bot pre { white-space: pre-wrap; font: inherit; margin: 6px 0 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.assist form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.assist .chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 12px; }
.assist .chips button { font-size: 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 4px 10px; cursor: pointer; color: var(--ink-2); }
.assist .chips button:hover { border-color: var(--accent); color: var(--accent); }

/* plano del valle */
.valley { background: var(--surface-2); border-radius: 8px; }
.valley .sea { fill: color-mix(in srgb, var(--info) 14%, var(--surface)); }
.valley .land { fill: var(--surface); }
.valley .contour { fill: none; stroke: color-mix(in srgb, var(--ink) 10%, transparent); stroke-width: .7; }
.valley .river { fill: none; stroke: color-mix(in srgb, var(--info) 40%, var(--surface)); stroke-width: 5; stroke-linecap: round; }
.valley .parcel { stroke: var(--surface); stroke-width: 1.2; cursor: pointer; transition: opacity .15s; }
.valley .parcel:hover, .valley .parcel.sel { stroke: var(--ink); stroke-width: 1.8; }
.valley .winery { fill: var(--ink); }
.valley text { paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.valley .lbl { fill: var(--muted); font-size: 11px; font-style: italic; font-family: var(--display); }
.legend-scale { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.legend-scale .ramp { height: 8px; width: 160px; border-radius: 4px; }

/* plano de bodega */
.cellar { background: var(--surface-2); border-radius: 8px; }
.cellar .zone { fill: none; stroke: var(--line); stroke-dasharray: 3 4; }
.cellar .zone-l { fill: var(--muted); font-size: 13px; }
.cellar .tank { cursor: pointer; }
.cellar .tank .shell { fill: var(--surface); stroke: var(--line); stroke-width: 1.4; }
.cellar .tank:hover .shell, .cellar .tank.sel .shell { stroke: var(--ink); stroke-width: 2; }
.cellar .tank .code { font-size: 12px; fill: var(--ink-2); font-weight: 600; text-anchor: middle; }
.cellar .tank .sub { font-size: 10.5px; fill: var(--muted); text-anchor: middle; }
.cellar .tank.alert .shell { stroke: var(--bad); stroke-width: 2; }
.cellar .bubble { fill: rgba(255,255,255,.75); }

/* Kanban CRM */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; }
.kanban .col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.kanban .col h4 { margin: 2px 4px 10px; font-size: 13px; display: flex; justify-content: space-between; }
.kanban .col.drop { outline: 2px dashed var(--accent); }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; font-size: 13px; }
.kcard b { display: block; font-weight: 600; }
.kcard small { color: var(--muted); }

/* calendario */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal > div, .cal > a { display: block; color: inherit; text-decoration: none; min-width: 0; min-height: 104px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px 7px; font-size: 12px; background: var(--surface); }
.cal .dow { min-height: 0; background: var(--surface-2); font-weight: 600; color: var(--muted); }
.cal .out { background: var(--surface-2); color: var(--muted); }
.cal .today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal .ev { display: block; margin-top: 4px; border-radius: 5px; padding: 2px 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.c2 { background: var(--gold-soft); color: var(--warn); }
.cal .ev.c3 { background: var(--info-soft); color: var(--info); }
.cal .ev.c4 { background: var(--bad-soft); color: var(--bad); }

/* árbol de trazabilidad */
.tree { list-style: none; margin: 0; padding-left: 0; }
.tree ul { list-style: none; padding-left: 22px; margin: 0; border-left: 1px solid var(--line); margin-left: 9px; }
.tree li { position: relative; padding: 5px 0 5px 12px; }
.tree ul > li::before { content: ""; position: absolute; left: 0; top: 17px; width: 10px; border-top: 1px solid var(--line); }
.tree .node { display: inline-flex; gap: 8px; align-items: center; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; }
.tree .node.bottle { border-color: var(--gold); }
.tree .node.lot { border-color: var(--accent); }
.tree details > summary { list-style: none; cursor: pointer; }
.tree details > summary::-webkit-details-marker { display: none; }

/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login .art { background: var(--side); color: #E8EEE9; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .art h2 { font-family: var(--display); font-weight: 500; font-size: 44px; line-height: 1.05; margin: 0; max-width: 12ch; position: relative; }
.login .art p { color: #9DB0A5; max-width: 40ch; position: relative; }
.login .art svg.bg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; }
.login .formside { display: grid; place-items: center; padding: 40px; }
.login form { width: min(380px, 100%); }
.login h1 { font-family: var(--display); font-weight: 500; font-size: 30px; margin: 0 0 6px; }
.demo-users { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 16px; }
.demo-users button { display: flex; width: 100%; justify-content: space-between; align-items: center; padding: 8px 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; margin-bottom: 6px; cursor: pointer; font-size: 13px; text-align: left; }
.demo-users button:hover { border-color: var(--accent); }
.demo-users small { color: var(--muted); }

/* pantalla de vendimia en directo */
.big-number { font-family: var(--display); font-weight: 500; font-size: 64px; line-height: 1; letter-spacing: -.02em; }
.scale-display { background: var(--side); color: #F4F1DE; border-radius: var(--radius); padding: 22px; font-family: ui-monospace, Menlo, monospace; }
.scale-display .w { font-size: 54px; letter-spacing: .04em; color: #E6C766; }

@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g-side { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 70; left: 0; width: 260px; transform: translateX(-100%); transition: transform .25s; }
  .side.on { transform: none; }
  .menu-toggle { display: inline-grid; }
  .top { padding: 10px 16px; }
  .page { padding: 20px 16px 50px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .who div { display: none; }
  .search kbd, .search span { display: none; }
  .search { flex: 0 0 36px; padding: 0; justify-content: center; }
  #theme-btn { display: none; }
  .page-head h1 { font-size: 28px; }
  .login { grid-template-columns: 1fr; }
  .login .art { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media print {
  .side, .top, .actions, .no-print { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
