/* ================================================================
   JulioAuto · Design System
   Tema: Dark editorial · Acento ámbar
   Fuentes: Instrument Serif · Geist · Geist Mono
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

/* ================================================================
   01 · TOKENS
   ================================================================ */

:root {
  /* Fondos */
  --bg:        oklch(0.155 0.007 60);
  --bg-deep:   oklch(0.12  0.007 60);
  --bg-card:   oklch(0.215 0.008 60);
  --bg-elev:   oklch(0.245 0.008 60);

  /* Acento */
  --accent:      oklch(0.78 0.16 55);
  --accent-soft: oklch(0.78 0.16 55 / 0.12);
  --accent-muted:oklch(0.78 0.16 55 / 0.25);

  /* Texto */
  --text:     oklch(0.97 0.005 80);
  --text-mut: oklch(0.60 0.008 70);
  --text-dim: oklch(0.42 0.006 60);

  /* Estados */
  --ok:     oklch(0.78 0.15 150);
  --warn:   oklch(0.82 0.15 80);
  --bad:    oklch(0.70 0.19 25);
  --info:   oklch(0.75 0.13 230);
  --purple: oklch(0.72 0.16 305);

  --ok-soft:     oklch(0.78 0.15 150 / 0.12);
  --warn-soft:   oklch(0.82 0.15 80  / 0.12);
  --bad-soft:    oklch(0.70 0.19 25  / 0.12);
  --info-soft:   oklch(0.75 0.13 230 / 0.12);
  --purple-soft: oklch(0.72 0.16 305 / 0.12);

  /* Bordes */
  --border:      oklch(0.30 0.008 60);
  --border-soft: oklch(0.25 0.007 60);

  /* Tipografía */
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-sans:    'Geist', system-ui, sans-serif;
  --font-mono:    'Geist Mono', 'Courier New', monospace;

  /* Espaciado base */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 18px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  /* Radios */
  --radius:    6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Sombras */
  --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.4);
  --shadow-md: 0 4px 16px oklch(0 0 0 / 0.45), 0 1px 3px oklch(0 0 0 / 0.3);
  --shadow-lg: 0 12px 40px oklch(0 0 0 / 0.55), 0 2px 8px oklch(0 0 0 / 0.3);
}

/* Fallbacks hex para navegadores sin soporte oklch */
@supports not (color: oklch(0 0 0)) {
  :root {
    --bg:        #1c1a17;
    --bg-deep:   #141210;
    --bg-card:   #252219;
    --bg-elev:   #2e2b22;
    --accent:    #e8a930;
    --accent-soft: rgba(232, 169, 48, 0.12);
    --text:      #f9f7f3;
    --text-mut:  #8c8070;
    --text-dim:  #5a5248;
    --ok:        #48bf85;
    --warn:      #d4a72c;
    --bad:       #d9503a;
    --info:      #4a9fd4;
    --purple:    #a06ed4;
    --border:     #3a3528;
    --border-soft:#2c2920;
  }
}

/* ================================================================
   02 · RESET & BASE
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; font-size: 14px; }

body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

em { font-style: italic; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ================================================================
   03 · SIDEBAR
   ================================================================ */

.sidebar {
  width: 232px;
  background: var(--bg-deep);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

/* Brand */
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.sb-brand-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: oklch(0.12 0.02 60);
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

.sb-brand-name {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.sb-brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* Search */
.sb-search {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 10px 8px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.sb-search:hover {
  border-color: var(--border);
  background: var(--bg-elev);
}
.sb-search span { flex: 1; }

/* Nav items */
.sb-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  margin: 1px 6px;
  border-radius: var(--radius);
  color: var(--text-mut);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.sb-item:hover {
  background: var(--bg-card);
  color: var(--text);
}
.sb-item.active {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-soft);
}
.sb-item.active .ico { color: var(--accent); }

.sb-item.parent .ico:last-child {
  color: var(--text-dim);
  margin-left: auto;
  transition: transform 0.15s;
}
.sb-item.parent:hover .ico:last-child { transform: translateX(2px); }

/* Footer avatar */
.sb-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
}

.av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-mut);
  flex-shrink: 0;
}

.who {
  font-size: 12.5px;
  line-height: 1.35;
}
.who small { font-size: 11px; color: var(--text-dim); }

/* ================================================================
   04 · MAIN & TOPBAR
   ================================================================ */

.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  flex: 1;
  min-width: 0;
}

.topbar {
  height: 48px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 12px;
  flex-shrink: 0;
}

/* Breadcrumbs */
.tb-crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-mut);
}
.tb-crumbs .sep { color: var(--text-dim); }
.tb-crumbs .cur { color: var(--text); font-weight: 500; }

.tb-spacer { flex: 1; }

.tb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ================================================================
   05 · PAGE AREA
   ================================================================ */

.page {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 48px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.page-hero {
  margin-bottom: 24px;
}

.page-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 38px;
  line-height: 1.08;
  letter-spacing: -0.022em;
  font-weight: 400;
  margin-bottom: 10px;
}
.page-title em { font-style: italic; color: var(--accent); }

.page-sub {
  font-size: 13.5px;
  color: var(--text-mut);
  line-height: 1.6;
  max-width: 68ch;
}

/* ================================================================
   06 · ALERTS
   ================================================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  border-left-width: 3px;
  border-left-color: var(--text-dim);
}
.alert.bad  { border-left-color: var(--bad);  background: color-mix(in oklch, var(--bad)  8%, var(--bg-card)); }
.alert.warn { border-left-color: var(--warn); background: color-mix(in oklch, var(--warn) 8%, var(--bg-card)); }
.alert.ok   { border-left-color: var(--ok);   background: color-mix(in oklch, var(--ok)   8%, var(--bg-card)); }
.alert.info { border-left-color: var(--info);  background: color-mix(in oklch, var(--info)  8%, var(--bg-card)); }

.alert .ic {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--bad-soft);
  color: var(--bad);
}
.alert.bad  .ic { background: var(--bad-soft);  color: var(--bad); }
.alert.warn .ic { background: var(--warn-soft); color: var(--warn); }
.alert.ok   .ic { background: var(--ok-soft);   color: var(--ok); }
.alert.info .ic { background: var(--info-soft);  color: var(--info); }

.alert .ttl  { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.alert .desc { font-size: 11.5px; color: var(--text-mut); margin-top: 2px; line-height: 1.4; }

/* ================================================================
   07 · KPI CARDS
   ================================================================ */

.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.kpi.warm { border-color: var(--accent-muted); }

.kpi-lbl {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.kpi-val {
  font-family: var(--font-display);
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.kpi-delta {
  font-family: var(--font-mono);
  font-size: 11px;
  margin-top: 6px;
}
.kpi-delta.up   { color: var(--ok); }
.kpi-delta.down { color: var(--bad); }
.kpi-delta.flat { color: var(--text-dim); }

/* ================================================================
   08 · CARDS
   ================================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.card-h {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-t {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-st {
  font-size: 11.5px;
  color: var(--text-mut);
  margin-top: 2px;
}

/* ================================================================
   09 · TABLA
   ================================================================ */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.tbl thead tr {
  border-bottom: 1px solid var(--border-soft);
}

.tbl th {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 500;
  text-align: left;
  padding: 6px 10px 8px;
}
.tbl th.num { text-align: right; }

.tbl tbody tr {
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.1s;
  cursor: pointer;
}
.tbl tbody tr:last-child { border-bottom: none; }
.tbl tbody tr:hover { background: var(--bg-elev); }

.tbl td {
  padding: 9px 10px;
  color: var(--text);
  vertical-align: middle;
}
.tbl td.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text-mut);
}

/* ================================================================
   10 · PILLS / BADGES
   ================================================================ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg-elev);
  color: var(--text-mut);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
}

.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.pill.ok     { background: var(--ok-soft);     color: var(--ok);     border-color: oklch(0.78 0.15 150 / 0.2); }
.pill.warn   { background: var(--warn-soft);   color: var(--warn);   border-color: oklch(0.82 0.15 80  / 0.2); }
.pill.bad    { background: var(--bad-soft);    color: var(--bad);    border-color: oklch(0.70 0.19 25  / 0.2); }
.pill.info   { background: var(--info-soft);   color: var(--info);   border-color: oklch(0.75 0.13 230 / 0.2); }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-muted); }
.pill.purple { background: var(--purple-soft); color: var(--purple); border-color: oklch(0.72 0.16 305 / 0.2); }

/* ================================================================
   11 · TEMPERATURA DE LEAD
   ================================================================ */

.temp {
  display: inline-flex;
  gap: 3px;
  align-items: flex-end;
}

/* barras de temperatura usando los <i> hijos */
.temp i {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.2s;
}
.temp i:nth-child(1) { height: 6px; }
.temp i:nth-child(2) { height: 9px; }
.temp i:nth-child(3) { height: 12px; }
.temp i:nth-child(4) { height: 15px; }
.temp i:nth-child(5) { height: 18px; }

/* Hot: todas rellenas — acento ámbar */
.temp.hot i { background: var(--accent); }

/* Warm: 3 rellenas */
.temp.warm i:nth-child(1),
.temp.warm i:nth-child(2),
.temp.warm i:nth-child(3) { background: var(--warn); }

/* Cold: 1 rellena */
.temp.cold i:nth-child(1) { background: var(--info); }

/* ================================================================
   12 · BOTONES
   ================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-mut);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: oklch(0.12 0.02 60);
  font-weight: 600;
}
.btn.primary:hover {
  background: oklch(0.83 0.16 55);
  border-color: oklch(0.83 0.16 55);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-mut);
}
.btn.ghost:hover {
  background: var(--bg-elev);
  border-color: var(--border-soft);
  color: var(--text);
}

.btn.sm {
  padding: 4px 10px;
  font-size: 11.5px;
}

/* ================================================================
   13 · FORMULARIOS
   ================================================================ */

.fld { display: flex; flex-direction: column; gap: 5px; }

.fld-row { display: grid; gap: 12px; }
.fld-row.c2 { grid-template-columns: 1fr 1fr; }
.fld-row.c3 { grid-template-columns: 1fr 1fr 1fr; }

.fld-lbl {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mut);
}
.fld-lbl .req { color: var(--bad); margin-left: 2px; }
.fld-lbl .hint { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); margin-left: 6px; }

.fld-in {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 8px 11px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.fld-in::placeholder { color: var(--text-dim); }
.fld-in:focus {
  border-color: var(--accent-muted);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.fld-in.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Segmented control */
.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}
.seg .opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 12px;
  color: var(--text-mut);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.seg .opt:hover { background: var(--bg-elev); color: var(--text); }
.seg .opt.on {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-weight: 500;
}

/* ================================================================
   14 · ÁTOMOS MENORES
   ================================================================ */

/* Keyboard shortcut */
.kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  margin-left: auto;
  line-height: 1.6;
}

/* ICO */
.ico {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Separador de breadcrumbs */
.sep { color: var(--text-dim); }

/* Dot genérico */
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  display: inline-block;
}

/* Pill "En línea" */
.pill.ok .dot { background: var(--ok); }

/* ================================================================
   15 · SCROLLBAR
   ================================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ================================================================
   16 · FOCUS & ACCESIBILIDAD
   ================================================================ */

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

/* ================================================================
   17 · UTILIDADES DE LAYOUT GENERALES
   ================================================================ */

.preview-stage {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100%;
}

/* ================================================================
   18 · GALERÍA DE STOCK
   ================================================================ */

/* Chip de filtro (dropdown / buscador) */
.fchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  color: var(--text-mid, var(--text));
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.fchip:hover { background: var(--bg-card); color: var(--text); }
.fchip .lbl { color: var(--text-mut); }

/* Elevación al hover (tarjetas de la grilla) */
.hover-lift { transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.hover-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border); }

/* Fondo al hover (filas de la lista) */
.hover-row { transition: background .12s ease; }
.hover-row:hover { background: var(--bg-elev); }

/* Punto de color del auto */
.color-chip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: inline-block;
  flex-shrink: 0;
}

/* Galería: grilla responsive */
.galeria-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 1100px) { .galeria-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px)  { .galeria-grid { grid-template-columns: minmax(0, 1fr); } }

/* Kanban de negociaciones: zona de drop */
.kanban-drop {
  border-radius: 10px;
  transition: background .12s ease, box-shadow .12s ease;
}
.kanban-drop.over {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-muted, var(--accent));
}

/* === Préstamos — utilidades del prototipo que faltaban === */
.display { font-family: var(--font-display); letter-spacing: -0.02em; }
.tabular { font-variant-numeric: tabular-nums; }
.av.md { width: 36px; height: 36px; font-size: 13px; }
.av.lg { width: 48px; height: 48px; font-size: 16px; }
.kpi.warm { background: var(--accent-soft); border-color: var(--accent-line); }
.toggle-grp { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-elev); border: 1px solid var(--border-soft); border-radius: 8px; }
.toggle-grp button { border: none; background: transparent; color: var(--text-mut); padding: 5px 11px; border-radius: 5px; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 500; }
.toggle-grp button.on { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow-sm); }
.photo-ph {
  background: repeating-linear-gradient(45deg, oklch(0.35 0.008 60) 0 1px, transparent 1px 8px), oklch(0.22 0.008 60);
  border: 1px solid var(--border-soft); display: grid; place-items: center;
  color: var(--text-dim); font-family: var(--font-mono); font-size: 11px; border-radius: 8px;
}
