/* ============================================================
   aluminio.css — ValdiviaLux v2.4
   Estética: Industrial Precision — acero, aluminio, oficio
   Responsive: mobile-first, breakpoints 480/768/1024px
   ============================================================ */

/* v2.11: sin tipografías externas (tipografía del sistema) */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Paleta ValdiviaLux: cristal & aluminio anodizado */
  --bg:         #f4f3ef;   /* arena cristal */
  --bg-alt:     #e8e6df;
  --surface:    #ffffff;
  --border:     #d4d2ca;
  --border-dark:#b0aea5;
  --accent:     #1d3a5f;   /* azul Valdivia (lago Calle-Calle) */
  --accent2:    #b8852c;   /* bronce dorado */
  --accent3:    #4a7eb6;   /* azul medio */
  --accent-lt:  #ecf2f9;   /* halo azul */
  --text:       #18181a;
  --text-muted: #6a6a62;
  --text-light: #9a9a90;
  --success:    #16803a;
  --danger:     #c42020;
  --warn:       #c07820;
  --info:       #1c5a8a;

  /* Tipografía */
  --font-body:  system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono:  ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', Consolas, 'Liberation Mono', monospace;
  --font-cond:  system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Espaciado */
  --sidebar-w:  230px;
  --sidebar-bg: var(--accent);   /* puede sobreescribirse por el tema */
  --topbar-h:   52px;
  --radius:     5px;
  --radius-lg:  8px;

  /* Sombras */
  --shadow:     0 1px 3px rgba(0,0,0,.07), 0 2px 8px rgba(0,0,0,.05);
  --shadow-md:  0 3px 12px rgba(0,0,0,.1);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.14);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout principal ──────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg, var(--accent));
  transition: background .2s;
  color: rgba(255,255,255,.82);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .28s cubic-bezier(.4,0,.2,1),
              width .28s cubic-bezier(.4,0,.2,1);
  z-index: 200;
}

/* Sidebar brand */
.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.sidebar-logo {
  font-size: 22px;
  font-family: var(--font-cond);
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: var(--accent2);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-cond);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.5px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15), 0 2px 4px rgba(192,120,32,.3);
}
.sidebar-brand-sub {
  font-size: 9.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* Sidebar nav sections */
.sidebar-section { padding: 8px 0 2px; }
.sidebar-section-label {
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 6px 16px 4px;
  font-family: var(--font-mono);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  cursor: pointer;
  color: rgba(255,255,255,.68);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s, border-left-color .15s;
  border-left: 3px solid transparent;
  user-select: none;
  white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,.09); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,.13);
  color: #fff;
  border-left-color: var(--accent2);
  font-weight: 600;
}
.nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: 10px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 10px;
  color: rgba(255,255,255,.25);
  font-family: var(--font-mono);
  line-height: 1.6;
  flex-shrink: 0;
}

/* ── Main wrap ─────────────────────────────────────────────── */
#main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  box-shadow: 0 1px 0 var(--border);
}
#topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}
#topbar-menu-btn:hover { background: var(--bg-alt); color: var(--text); }
#topbar-brand { font-size: 13px; color: var(--text-muted); font-weight: 500; }
#topbar-sep { color: var(--border-dark); font-size: 12px; }
#topbar-breadcrumb {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-cond);
  letter-spacing: 0.3px;
}
.topbar-spacer { flex: 1; }
#topbar-time {
  font-size: 11.5px;
  color: var(--text-light);
  font-family: var(--font-mono);
}

/* ── Main content ──────────────────────────────────────────── */
#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Page structure ────────────────────────────────────────── */
.p-page {
  padding: 20px;
  max-width: 1400px;
  animation: fadeIn .18s ease;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-cond);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.1;
}
.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card-title {
  font-family: var(--font-cond);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Stats grid ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
  transition: box-shadow .15s, transform .15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon { font-size: 26px; flex-shrink: 0; }
.stat-value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1.1;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  margin-top: 1px;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 400px;
}
.data-table th {
  background: var(--bg-alt);
  color: var(--text-muted);
  font-family: var(--font-cond);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 9px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover td { background: var(--accent-lt); }
.data-table .num { text-align: right; font-family: var(--font-mono); }

/* ── Botones ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .12s, box-shadow .12s, transform .1s;
  border: none;
  line-height: 1.4;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-icon { padding: 7px; gap: 0; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-family: var(--font-cond);
}
.field-hint { font-size: 11px; color: var(--text-light); }
.input {
  width: 100%;
  padding: 8px 10px;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(28,58,90,.1);
}
.input:disabled { background: var(--bg-alt); color: var(--text-muted); cursor: not-allowed; }
textarea.input { resize: vertical; min-height: 64px; }
select.input { cursor: pointer; }

/* ── Toolbar / Filtros ─────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-bar { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-btn {
  padding: 5px 13px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ── Item rows (presupuesto) ───────────────────────────────── */
.item-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  margin-bottom: 7px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: box-shadow .15s, border-color .15s;
}
.item-row:hover { box-shadow: var(--shadow-md); border-color: var(--border-dark); }
.item-row-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.item-tag {
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 3px;
  min-width: 32px;
  text-align: center;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.item-info { flex: 1; min-width: 0; }
.item-line {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  font-size: 12px;
  margin-top: 3px;
}
.item-sep { color: var(--border-dark); }
.item-dims { font-family: var(--font-mono); color: var(--text-muted); font-size: 11.5px; }
.item-color { color: var(--accent2); font-weight: 600; }
.item-qty { color: var(--text-muted); }
.item-glass { font-size: 11px; color: var(--text-muted); }
.item-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.item-prices { text-align: right; flex-shrink: 0; }
.item-unit { font-size: 11px; color: var(--text-muted); }
.item-total {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--success);
}
.item-row-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Chips por tipo de material */
.breakdown-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.3px;
}
.chip-P { background: #dbeafe; color: #1e40af; }
.chip-Q { background: #fef3c7; color: #78350f; }
.chip-B { background: #d1fae5; color: #064e3b; }
.chip-V { background: #ede9fe; color: #4c1d95; }

/* ── Budget totals ─────────────────────────────────────────── */
.budget-totals { min-width: 270px; }
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  gap: 16px;
}
.totals-row.total {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 15px;
  border-radius: var(--radius);
  border-top: none;
  margin-top: 4px;
}
.totals-row .breakdown-chip { font-size: 9.5px; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,14,20,.55);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 920px;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleIn .18s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}
.modal-title {
  font-family: var(--font-cond);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius);
  line-height: 1;
  transition: background .12s;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

/* ── Quote Item Editor ──────────────────────────────────────── */
.qie-body {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 18px;
  min-height: 320px;
}
.qie-form { display: flex; flex-direction: column; gap: 12px; }
.qie-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.qie-row-compact { gap: 10px; }
.qie-row-dims { align-items: flex-end; gap: 6px; }
.qie-dims-x {
  font-size: 18px;
  color: var(--text-muted);
  padding-bottom: 8px;
  flex-shrink: 0;
}
.qie-full { flex: 1; min-width: 160px; }
.input-tag {
  text-transform: uppercase;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}
.validation-msg { font-size: 12px; color: var(--danger); min-height: 18px; }

/* Calc panel */
.qie-calc {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-y: auto;
  max-height: 480px;
}
.qie-calc-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-family: var(--font-cond);
}
.calc-groups { margin-bottom: 8px; }
.calc-group-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  background: var(--surface);
  border-radius: 4px;
  margin-bottom: 3px;
  border: 1px solid var(--border);
}
.calc-group-label {
  font-size: 9px;
  letter-spacing: 1.8px;
  color: var(--text-muted);
  font-family: var(--font-cond);
  font-weight: 600;
}
.calc-group-val { font-size: 12px; font-family: var(--font-mono); }
.calc-unit-row, .calc-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.calc-total-row {
  font-weight: 700;
  color: var(--accent);
  border-top: 2px solid var(--accent);
  margin-top: 2px;
  font-size: 14px;
}
.calc-placeholder { font-size: 12px; color: var(--text-light); font-style: italic; }

/* Materials list */
.materials-list { margin-top: 8px; }
.mat-row {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 3px 0;
  border-bottom: 1px dotted var(--border);
  line-height: 1.5;
  word-break: break-all;
}


/* ── Budget totals ──────────────────────────────────────────── */
.subtotals-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  padding: 10px 0 4px;
}
.sub-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  min-width: 260px;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--border);
  color: var(--text-muted);
}
.sub-total-row {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  border-top: 2px solid var(--accent);
  border-bottom: none;
  padding-top: 6px;
}

/* ── Quote Item Editor: two-column layout ───────────────────── */
.qie-form-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
/* ── Combobox buscador de líneas ───────────────────────────────────── */
.line-combo-wrap {
  position: relative;
  width: 100%;
}
.line-combo-input {
  width: 100%;
  box-sizing: border-box;
}
.line-combo-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 1200;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0,0,0,.15);
  max-height: 240px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 4px 0;
}
.line-combo-dropdown.open { display: block; }
.line-combo-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.line-combo-item:hover,
.line-combo-highlighted {
  background: var(--accent);
  color: var(--on-accent);
}
.line-combo-empty {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-muted);
  list-style: none;
}
/* ── fin combobox ──────────────────────────────────────────────────── */

.qie-calc-col {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-y: auto;
  max-height: 520px;
  min-width: 0;
}
.calc-summary {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.calc-materials {
  margin-top: 8px;
}

/* ── Cut plan ───────────────────────────────────────────────── */
.cut-color-section { margin-bottom: 18px; }
.cut-color-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius) var(--radius) 0 0;
}
.cut-color-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  padding: 2px 8px;
  background: rgba(255,255,255,.2);
  border-radius: 3px;
}
.cut-color-name { font-size: 13px; font-weight: 600; font-family: var(--font-cond); }
.cut-profile-card {
  border: 1px solid var(--border);
  border-top: none;
  background: var(--surface);
  padding: 12px;
  margin-bottom: 3px;
}
.cut-profile-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
}
.cut-profile-desc { color: var(--text-muted); font-size: 13px; flex: 1; min-width: 0; }
.cut-profile-meta { display: flex; gap: 14px; flex-wrap: wrap; }
.cut-stat { font-size: 12px; color: var(--text-muted); }
.cut-stat strong { color: var(--text); font-family: var(--font-mono); }
.cut-bars-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cut-bars-table th {
  background: var(--bg-alt);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 5px 8px;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-cond);
}
.cut-bars-table th.num, .cut-bars-table td.num { text-align: right; }
.cut-bars-table td {
  padding: 5px 8px;
  border-bottom: 1px dotted var(--border);
  vertical-align: middle;
}
.cut-cuts-cell { max-width: 300px; word-break: break-word; font-family: var(--font-mono); font-size: 11px; line-height: 1.6; }
.cut-totals-bar {
  margin-top: 10px;
  padding: 9px 14px;
  background: var(--bg-alt);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.cut-totals-bar strong { color: var(--text); font-family: var(--font-mono); }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* ── Misc utilities ────────────────────────────────────────── */
.mono { font-family: var(--font-mono); }
.bold { font-weight: 700; }
.accent { color: var(--accent2); }
.num { text-align: right; }
.muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
}

/* ── Loading / Seed screen ─────────────────────────────────── */

/* ── Global Search (Ctrl+K) ─────────────────────────────────── */
.gs-item { outline: none; }
.gs-item:hover,
.gs-item-selected {
  background: var(--accent-lt, rgba(29,58,95,.08));
}
.gs-input::placeholder { color: var(--text-muted); }
.gs-input:focus { outline: none; }
@media (prefers-color-scheme: dark) {
  .gs-item-selected { background: rgba(255,255,255,.07); }
}

#seed-screen {
  position: fixed; inset: 0;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 9999;
  padding: 24px;
}
.seed-logo {
  font-size: 56px;
  margin-bottom: 4px;
  font-family: var(--font-cond);
  font-weight: 700;
  color: var(--accent2);
  width: 88px; height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(192,120,32,.1);
  border: 2px solid var(--accent2);
  border-radius: 12px;
  animation: pulse 2.4s ease-in-out infinite;
}
.seed-title {
  font-family: var(--font-cond);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
}
.seed-sub {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: .5;
  font-family: var(--font-mono);
}
.seed-bar-wrap {
  width: min(320px, 80vw);
  height: 5px;
  background: rgba(255,255,255,.18);
  border-radius: 3px;
  overflow: hidden;
}
.seed-bar {
  height: 100%;
  background: var(--accent2);
  border-radius: 3px;
  transition: width .4s ease;
  width: 0%;
}
.seed-msg {
  font-size: 12px;
  opacity: .6;
  font-family: var(--font-mono);
  text-align: center;
  max-width: 300px;
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn  { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes slideUp  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse    { 0%,100% { opacity: 1; } 50% { opacity: .6; } }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile First
   480px: small phones
   768px: tablets / large phones landscape
   1024px: small laptops / tablets landscape
   ══════════════════════════════════════════════════════════════ */

/* ── MOBILE (< 768px) ──────────────────────────────────────── */
@media (max-width: 767px) {

  /* Sidebar: drawer lateral oculto */
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 300;
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Overlay para cerrar el drawer */
  #sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 290;
  }
  #sidebar-overlay.visible { display: block; }

  /* Botón menú visible */
  #topbar-menu-btn { display: flex; }

  /* Main ocupa todo el ancho */
  #main-wrap { width: 100%; }

  /* Topbar más compacto */
  #topbar { padding: 0 14px; gap: 8px; }
  #topbar-brand { display: none; }
  #topbar-sep { display: none; }
  #topbar-time { font-size: 10px; }

  /* Páginas sin padding excesivo */
  .p-page { padding: 14px; }

  /* Stats: 2×2 en lugar de 4×1 */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-value { font-size: 20px; }
  .stat-icon { font-size: 22px; }

  /* Form grid: 1 columna */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Budget item rows: apilados */
  .item-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
  }
  .item-row-main { width: 100%; gap: 8px; }
  .item-prices { align-self: flex-end; }
  .item-row-actions { align-self: flex-end; }

  /* Budget totals: ancho completo */
  .budget-totals { min-width: 0; width: 100%; }

  /* Modal: ancho completo con margen inferior */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: slideUp .22s ease;
  }

  /* Quote item editor: 1 columna */
  .qie-body {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .qie-calc { max-height: none; }

  /* Page header: apilar */
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-actions { width: 100%; }

  /* Filter bar scroll horizontal */
  .filter-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .filter-btn { flex-shrink: 0; }

  /* Ocultar columnas de tabla menos importantes */
  .data-table .col-hide-mobile { display: none; }

  /* Cut plan: tabla con scroll */
  .cut-bars-table th,
  .cut-bars-table td { padding: 4px 6px; font-size: 11px; }
  .cut-cuts-cell { max-width: 160px; }

  /* Topbar breadcrumb más corto */
  #topbar-breadcrumb { font-size: 13px; }

  /* Cards: padding reducido */
  .card { padding: 14px; }

  /* Toolbar: wrap completo */
  .toolbar { gap: 6px; }
  .toolbar .input { min-width: 0; width: 100%; }
}

/* ── TABLET (768px – 1023px) ───────────────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {

  /* Sidebar estrecho como iconos */
  #sidebar { width: var(--sidebar-w); }

  .p-page { padding: 18px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .form-grid { grid-template-columns: repeat(2, 1fr); }

  /* Modal: tamaño medio */
  .modal-box { max-width: 700px; }

  /* QIE: 1 columna (calc debajo) */
  .qie-body { grid-template-columns: 1fr; }
  .qie-calc { max-height: none; }
}

/* ── DESKTOP (≥ 1024px) ────────────────────────────────────── */
@media (min-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .form-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .qie-body { grid-template-columns: 1fr 260px; }
}

/* ── LARGE DESKTOP (≥ 1280px) ─────────────────────────────── */
@media (min-width: 1280px) {
  .p-page { padding: 24px; }
  .card { padding: 20px; }
}

/* ── Print styles ───────────────────────────────────────────── */
@media print {
  #sidebar, #topbar, #topbar-menu-btn { display: none !important; }
  #main-wrap { overflow: visible; }
  #main-content { overflow: visible; }
  .p-page { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .btn { display: none; }
  .item-row-actions { display: none; }
  .page-header .page-actions { display: none; }
}

/* ── Extra mobile: very small phones (< 380px) ──────────────── */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { flex-direction: row; }
  .page-title { font-size: 18px; }
  .item-tag { min-width: 28px; font-size: 10px; }
  .breakdown-chip { font-size: 9.5px; padding: 1px 5px; }
}

/* ── Tablet portrait specific ───────────────────────────────── */
@media (min-width: 600px) and (max-width: 767px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-overlay { align-items: center; padding: 16px; }
  .modal-box {
    max-height: 85vh;
    border-radius: var(--radius-lg);
    animation: scaleIn .18s ease;
  }
}

/* ── Touch-friendly interactive targets ─────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets on touch */
  .nav-item { padding: 12px 16px; }
  .btn { min-height: 40px; }
  .filter-btn { padding: 7px 14px; min-height: 36px; }
  .input { padding: 10px 12px; font-size: 15px; }
  .data-table td { padding: 12px; }
  .item-row { padding: 13px 14px; }
  .modal-close { padding: 8px 12px; }
}

/* ── Polish: better visual hierarchy ────────────────────────── */

/* Item row: better mobile alignment */
@media (max-width: 767px) {
  .item-row-main { flex-direction: column; align-items: stretch; }
  .item-tag { align-self: flex-start; }
  .item-info { width: 100%; }
  .item-prices { align-self: stretch; text-align: right; }
  .item-line { white-space: normal; }
}

/* Page-actions wrap on mobile */
.page-actions .btn { flex: 1 1 auto; min-width: 110px; }
@media (max-width: 480px) {
  .page-actions .btn { flex: 1 1 100%; min-width: 0; justify-content: center; }
}

/* Form actions / footer alignment */
.modal-footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal-footer .btn { min-height: 38px; }
@media (max-width: 480px) {
  .modal-footer { flex-direction: column-reverse; align-items: stretch; }
  .modal-footer .btn { width: 100%; justify-content: center; }
  .modal-footer > div { width: 100%; }
  .modal-footer > div .btn { width: 100%; }
}

/* QIE: better mobile spacing */
@media (max-width: 480px) {
  .qie-row-dims { flex-direction: column; }
  .qie-row-dims .field { width: 100%; }
  .qie-dims-x { display: none; }
  .qie-row-compact { flex-direction: column; align-items: stretch; }
}

/* Cut plan: better spacing on mobile */
@media (max-width: 767px) {
  .cut-profile-header { flex-direction: column; align-items: flex-start; gap: 4px; }
  .cut-profile-meta { gap: 8px; }
  .cut-stat { font-size: 11px; }
  .cut-bars-table { font-size: 10.5px; }
  .cut-bars-table th, .cut-bars-table td { padding: 4px 5px; }
  .cut-cuts-cell { max-width: 140px; font-size: 10px; }
}

/* Improved focus states (a11y) */
.btn:focus-visible,
.input:focus-visible,
.filter-btn:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

/* Empty state with icon */
.empty-state::before {
  content: '';
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  background: var(--bg-alt);
  border-radius: 50%;
  opacity: .5;
}

/* Card title flex alignment */
.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.card-title-row .card-title { margin: 0; }

/* Inline label-value pair (read-only display) */
.kv-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  font-size: 13px;
}
.kv-grid .key { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.kv-grid .val { font-weight: 600; }

/* Scroll bar always visible on tables */
.table-wrap::-webkit-scrollbar { height: 8px; }

/* Top loader bar (visual polish) */
@keyframes loaderBar {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Section dividers */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* Make seed screen nicer */
.seed-version-tag {
  display: inline-block;
  padding: 2px 10px;
  background: rgba(255,255,255,.1);
  border-radius: 12px;
  font-size: 10px;
  letter-spacing: 2px;
  font-family: var(--font-mono);
  margin-top: 6px;
  text-transform: uppercase;
  opacity: .8;
}

/* Better button inside ghost btn group */
.btn-group { display: inline-flex; border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.btn-group .btn { border-radius: 0; border: none; box-shadow: none; }
.btn-group .btn:not(:last-child) { border-right: 1px solid var(--border); }

/* ── Final Polish ─────────────────────────────────────────────────────────── */

/* Page-actions: better wrapping on mobile */
.page-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.page-actions .btn { white-space: nowrap; }

/* Filter bar with horizontal scroll on mobile */
@media (max-width: 480px) {
  .page-actions { width: 100%; }
  .page-actions .btn { font-size: 12px; padding: 7px 10px; }
}

/* Card title row consistency */
.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.card-title-row .card-title { margin: 0; }

/* Info chip in dashboard catalogs */
.cat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: border-color .12s, transform .1s;
}
.cat-chip:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Better hover state for sidebar item */
.nav-item:active { background: rgba(255,255,255,.18); }

/* Hide elements with --hidden modifier */
.hidden { display: none !important; }

/* Improved seed bar visual */
.seed-bar { background: linear-gradient(90deg, var(--accent2) 0%, #e08c30 100%); }

/* Print-only branding */
@media print {
  .page .hdr .company { font-size: 18pt; }
}

/* Better focus on click-to-edit rows */
.item-row:focus-within { box-shadow: 0 0 0 2px var(--accent2); outline: none; }

/* Skeleton loader for async content */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 0%, var(--bg) 50%, var(--bg-alt) 100%);
  background-size: 200% 100%;
  animation: skel 1.5s infinite;
  border-radius: 4px;
}
@keyframes skel {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Brand color accents */
.brand-accent { color: var(--accent2); }

/* Ensure form fields don't shrink unexpectedly in flex layouts */
.field { min-width: 0; }

/* ── ValdiviaLux brand identity ──────────────────────────────────────────── */

/* VL logo: refined typography */
.sidebar-logo-icon {
  background: linear-gradient(135deg, #b8852c 0%, #d99f3d 100%);
  letter-spacing: -1px;
  font-family: 'Barlow Condensed', sans-serif;
  font-style: italic;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}

/* Seed logo: more elegant for VL brand */
.seed-logo {
  font-family: var(--font-cond);
  font-style: italic;
  background: linear-gradient(135deg, #b8852c 0%, #d99f3d 100%);
  color: #fff !important;
  border: none !important;
  letter-spacing: -2px;
  text-shadow: 0 2px 4px rgba(0,0,0,.4);
}

/* Subtle background pattern (cristal/glass effect) */
body {
  background-image:
    radial-gradient(circle at 0% 0%, rgba(184,133,44,0.03) 0%, transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(29,58,95,0.04) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Topbar accent line */
#topbar {
  position: relative;
}
#topbar::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent2) 0%, transparent 60%);
  pointer-events: none;
}

/* Card hover subtle */
.card { transition: box-shadow .18s; }
.card:hover { box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06); }

/* Stat card: elegant border accent */
.stat-card {
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent2) 0%, var(--accent) 100%);
  opacity: 0;
  transition: opacity .2s;
}
.stat-card:hover::before { opacity: 0.4; }

/* Item tag: match brand */
.item-tag {
  background: linear-gradient(135deg, var(--accent) 0%, #2a4f7a 100%);
  letter-spacing: 0.5px;
}

/* Button primary: subtle gradient */
.btn[style*="--accent"]:not(:hover) {
  /* brand primary buttons */
}

/* Modal title typography */
.modal-title {
  letter-spacing: 0.2px;
  font-style: italic;
}

/* Print: brand line on documents */
@media print {
  .page .hdr {
    border-bottom: 2.5px solid var(--accent);
    position: relative;
  }
  .page .hdr::after {
    content: '';
    position: absolute;
    bottom: -2.5px; left: 0;
    width: 60px;
    height: 2.5px;
    background: var(--accent2);
  }
}
