:root {
    --primary: #203023;
    --accent: #d4af37;
    --bg: #fdfdfd;
    --border: #eef0f2;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --sidebar-bg: #203023;
    --white: #ffffff;
    --success: #27ae60;

    /* ── Hauka Design System tokens (model components) ── */
    --hk-primary:   #203023;
    --hk-primary-2: #2a3d2d;
    --hk-accent:    #d4af37;
    --hk-bg:        #fafaf7;
    --hk-panel:     #ffffff;
    --hk-border:    #ebece6;
    --hk-border-2:  #e1e3dc;
    --hk-text:      #1c2620;
    --hk-muted:     #7a8581;
    --hk-soft:      #f4f5f0;
    --hk-warn:      #c0392b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); display: flex; height: 100vh; overflow: hidden; }

/* Welcome Screen */
#portada {
    position: fixed; inset: 0; background: var(--primary); display: flex;
    align-items: center; justify-content: center; z-index: 2000; color: white;
}
.welcome-card {
    background: rgba(255,255,255,0.05); backdrop-filter: blur(20px);
    padding: 3rem; border-radius: 24px; width: 100%; max-width: 500px;
    border: 1px solid rgba(255,255,255,0.1); display: flex; flex-direction: column; gap: 1.5rem;
}
.portada-input {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s;
}

.portada-input option {
    background: white;
    color: #203023;
}

/* Sidebar */
.sidebar { width: 200px; background: var(--sidebar-bg); color: white; display: flex; flex-direction: column; padding: 1rem; flex-shrink: 0; }
.logo { width: 120px; filter: invert(1); margin-bottom: 2rem; cursor: pointer; }
.nav-menu { list-style: none; flex: 1; }
.nav-item { padding: 0.8rem 1rem; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.5rem; opacity: 0.7; }
.nav-item.active { background: var(--accent); color: black; font-weight: 600; opacity: 1; }

.project-tag { background: rgba(255,255,255,0.1); padding: 0.8rem; border-radius: 12px; font-size: 0.75rem; margin-top: auto; }

/* Main Area */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #fff; }

/* Search & Results Panel */
.search-panel { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); background: #fbfbfc; flex-shrink: 0; }
.search-input-wrapper { position: relative; margin-bottom: 1rem; }
.big-search { 
    width: 100%; padding: 1rem 1rem 1rem 3rem; border-radius: 12px; 
    border: 1px solid var(--border); font-size: 1rem; outline: none; box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.big-search:focus { border-color: var(--accent); }

.results-grid { 
    max-height: 400px; overflow-y: auto; border: 1px solid var(--border); 
    border-radius: 12px; background: white; margin-top: 0.5rem; display: none;
}
.result-item { 
    padding: 1rem; border-bottom: 1px solid var(--border); display: flex; 
    align-items: center; gap: 1rem; cursor: pointer; transition: 0.2s;
}
.result-item:hover { background: #f8fafc; }
.result-item img { width: 50px; height: 50px; object-fit: contain; }

/* Configurator Panel */
.configurator { 
    padding: 1rem 1.5rem; background: #fff; border-bottom: 1px solid var(--border); 
    display: none; animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.config-row { display: grid; grid-template-columns: 80px 1fr 1fr 1fr auto; gap: 1.5rem; align-items: end; }
.config-field { display: flex; flex-direction: column; gap: 0.4rem; }
.config-field label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.config-input { 
    padding: 0.8rem; border: 1.5px solid var(--border); border-radius: 8px; 
    font-size: 0.9rem; outline: none; background: #fcfcfd;
}
.config-input:focus { border-color: var(--primary); }

/* Cart / Quote Table */
.quote-container { flex: 1; overflow-y: auto; padding: 0.5rem 1rem; }
.quote-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.quote-table th { 
    text-align: left; padding: 0.6rem; border-bottom: 2px solid var(--primary); 
    font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase;
}
.quote-table td { padding: 0.6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }

.quote-row { transition: background 0.2s; cursor: pointer; }
.quote-row:hover { background: #f4f7fa; }
.quote-row.editing-row { background: #fdf8e8 !important; box-shadow: inset 3px 0 0 var(--accent); }

.item-config-summary { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.3rem; }

/* Totals Panel */
.totals-panel { 
    width: 260px; border-left: 1px solid var(--border); background: #fbfbfc; 
    display: flex; flex-direction: column; padding: 1.5rem; flex-shrink: 0;
}
.total-box { margin-top: auto; border-top: 2px solid var(--primary); padding-top: 1.5rem; }
.total-line { display: flex; justify-content: space-between; margin-bottom: 0.8rem; }

.btn-primary { 
    background: var(--primary); color: white; border: none; padding: 1rem; 
    border-radius: 10px; font-weight: 700; cursor: pointer; transition: 0.3s;
}
.btn-accent { 
    background: var(--accent); color: black; border: none; padding: 1rem; 
    border-radius: 10px; font-weight: 700; cursor: pointer; transition: 0.3s;
}

.item-config-summary { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.3rem; }

/* Large Image Preview */
.config-preview-img {
    width: 180px; 
    height: 180px;
    object-fit: contain;
    border-radius: 12px;
    background: #f8f8f8;
    border: 1px solid var(--border);
    margin-right: 1rem;
}

.config-container-flex {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
}

.config-form {
    flex: 1;
}

.qty-input {
    width: 60px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
}

.pos-input {
    width: 50px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
    font-weight: bold;
}

/* Utils */
.badge { background: #eee; padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; font-weight: 700; }
.pts-val { font-weight: 800; color: var(--primary); font-size: 1.1rem; }

@media print {
    body > *:not(#printArea) { display: none !important; }
    #printArea { 
        display: block !important; 
        position: absolute; 
        top: 0; 
        left: 0; 
        width: 100%; 
        background: white; 
    }
    html, body { overflow: visible !important; height: auto !important; width: 100% !important; margin: 0; padding: 0; }
    
    @page {
        margin: 20mm;
        @bottom-right {
            content: counter(page) " / " counter(pages);
            font-family: 'Segoe UI', sans-serif;
            font-size: 9px;
            color: #666;
        }
    }
}

/* Action Dropdown Menu */
.actions-dropdown {
    position: relative;
    width: 100%;
}
.dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    margin-bottom: 8px;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.dropdown-item {
    padding: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: #f8fafc; color: var(--accent); }

.history-edit {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 8px;
    font-family: inherit;
    font-size: inherit;
    width: 100%;
    color: inherit;
    font-weight: inherit;
}
.history-edit:hover {
    border-color: #eee;
    background: #fdfdfd;
}
.history-edit:focus {
    border-color: var(--accent);
    outline: none;
    background: white;
    box-shadow: 0 0 5px rgba(212, 175, 55, 0.2);
}

#printArea { display: none; }

/* ── SISTEMA DE MODELOS ─────────────────────────────────────────────────────── */

/* Imagen cuadrada con crop (modelos, swatches) */
.modelo-img-sq {
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    display: block;
}

/* Card de modelo en el modal */
.modelo-card-modal {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 0.75rem;
    transition: border-color 0.2s;
}
.modelo-card-modal:hover {
    border-color: rgba(212,175,55,0.3);
}

/* Labels del formulario sobre fondo oscuro */
.form-label-dark {
    font-size: 0.58rem;
    opacity: 0.5;
    color: white;
    font-weight: 700;
    text-transform: uppercase;
    display: block;
    margin-bottom: 3px;
}

/* Título de sección dentro del form */
.form-section-dark {
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 0.4rem;
    margin-top: 0.2rem;
}

/* Botones de navegación de modelos en sidebar */
.btn-modelo-nav {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    border-radius: 6px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.btn-modelo-nav:hover {
    background: rgba(212,175,55,0.2);
    border-color: var(--accent);
    color: var(--accent);
}

/* Botón guardar proyecto deshabilitado */
#btnStartProject:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ─────────────────────────────────────────────────────────────────────────── */

/* Animaciones */
.spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}


/* ══════════════════════════════════════════════════════════════════════════
   HAUKA MODEL COMPONENTS  —  design handoff integration
   ══════════════════════════════════════════════════════════════════════════ */

.hk * { box-sizing: border-box; margin: 0; padding: 0; }
.hk { font-family: 'Inter', system-ui, sans-serif; color: var(--hk-text); -webkit-font-smoothing: antialiased; letter-spacing: -0.005em; }
.hk button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ── MODEL CARD (lista en modal) ── */
.model-card {
  background: white;
  border: 1px solid var(--hk-border);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  grid-template-columns: 156px 1fr;
  gap: 18px;
  transition: 150ms;
  position: relative;
}
.model-card:hover {
  border-color: var(--hk-border-2);
  box-shadow: 0 8px 24px rgba(20,30,25,.06);
}
.model-card.active {
  border-color: var(--hk-primary);
  box-shadow: 0 0 0 3px rgba(32,48,35,.06), 0 8px 24px rgba(20,30,25,.08);
}
.model-card .img-block {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--hk-soft);
  aspect-ratio: 1;
  border: 1px solid var(--hk-border);
}
.model-card .img-block img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.model-card .img-block .letter {
  position: absolute; top: 8px; left: 8px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: white;
  color: var(--hk-primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  box-shadow: 0 4px 10px rgba(0,0,0,.1);
}
.model-card .meta {
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0;
}
.model-card .head-row {
  display: flex; align-items: flex-start; gap: 10px;
}
.model-card .head-row .name-block { flex: 1; min-width: 0; }
.model-card .name {
  font-size: 16px; font-weight: 700; letter-spacing: -.01em; color: var(--hk-text);
}
.model-card .breadcrumb {
  font-size: 11px; color: var(--hk-muted); margin-top: 3px;
  display: flex; align-items: center; gap: 6px;
}
.model-card .breadcrumb .sep { opacity: .4; }
.model-card .breadcrumb .col {
  font-weight: 600; color: var(--hk-text);
  background: var(--hk-soft); padding: 1px 6px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  letter-spacing: .04em; text-transform: uppercase;
}
.model-card .actions { display: flex; gap: 4px; }
.model-card .actions button {
  width: 28px; height: 28px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--hk-muted); transition: 120ms;
}
.model-card .actions button:hover { background: var(--hk-soft); color: var(--hk-text); }
.model-card .actions button.danger:hover { background: #fbe9e7; color: var(--hk-warn); }

/* ── SWATCHES ── */
.swatches { display: flex; flex-direction: column; gap: 7px; }
.swatch {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px; align-items: center; padding: 4px 0;
}
.swatch .chip {
  width: 36px; height: 36px; border-radius: 7px;
  border: 1px solid rgba(0,0,0,.08);
  position: relative; overflow: hidden;
  background-size: cover; background-position: center; flex-shrink: 0;
}
.swatch .chip::after {
  content: ''; position: absolute; inset: 0;
  border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.swatch .label-block { min-width: 0; }
.swatch .role {
  font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  font-weight: 700; color: var(--hk-muted);
}
.swatch .name-finish {
  font-size: 12.5px; font-weight: 600; color: var(--hk-text); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.swatch .ref-tag {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700;
  color: var(--hk-muted); background: var(--hk-soft);
  padding: 3px 7px; border-radius: 5px; letter-spacing: .04em; white-space: nowrap;
}

/* ── EMPTY CARD ── */
.empty-card {
  border: 1.5px dashed var(--hk-border-2);
  background: var(--hk-soft); border-radius: 14px;
  padding: 32px; text-align: center; color: var(--hk-muted); font-size: 13px;
}
.empty-card b { color: var(--hk-text); display: block; margin-bottom: 4px; font-size: 14px; }

/* ── SIDEBAR MODEL SELECTOR ── */
.model-selector {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.model-selector .top { display: flex; align-items: center; gap: 8px; }
.model-selector .label {
  font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  font-weight: 700; color: rgba(255,255,255,.5);
}
.model-selector .top .pager {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,.2); border-radius: 6px; padding: 2px;
}
.model-selector .pager button {
  width: 22px; height: 22px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.7); transition: 120ms;
}
.model-selector .pager button:hover:not(:disabled) {
  background: rgba(255,255,255,.1); color: white;
}
.model-selector .pager button:disabled { opacity: .3; cursor: not-allowed; }
.model-selector .pager .pos {
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px;
  color: rgba(255,255,255,.7); padding: 0 4px; font-weight: 600;
}
.model-selector .id-row { display: flex; align-items: center; gap: 10px; }
.model-selector .id-letter {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--hk-accent); color: #1a2118;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; flex-shrink: 0;
}
.model-selector .id-info { min-width: 0; flex: 1; }
.model-selector .id-info .name {
  font-size: 13px; font-weight: 700; color: white;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.model-selector .id-info .col {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px;
  letter-spacing: .08em; color: var(--hk-accent);
  text-transform: uppercase; margin-top: 2px;
}
/* ── MODELO ACTIVO: lista de especificaciones ── */
.model-spec-list {
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(0,0,0,.18); padding: 8px 10px; border-radius: 8px;
  margin-top: 2px;
}
.msl-row {
  display: flex; flex-direction: column; gap: 2px;
}
.msl-role {
  font-size: 7.5px; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; color: rgba(255,255,255,.38);
}
.msl-val {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; font-weight: 600;
  color: rgba(255,255,255,.85); letter-spacing: .02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msl-val.msl-empty { color: rgba(255,255,255,.28); font-style: italic; font-family: inherit; }
.model-selector .actions { display: flex; gap: 6px; }
.model-selector .actions .add-btn {
  flex: 1; padding: 8px 10px; border-radius: 8px;
  background: rgba(212,175,55,.12); border: 1px solid rgba(212,175,55,.25);
  color: var(--hk-accent); font-size: 11px; font-weight: 700; letter-spacing: .04em;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-transform: uppercase; transition: 120ms;
}
.model-selector .actions .add-btn:hover {
  background: rgba(212,175,55,.2); border-color: rgba(212,175,55,.5);
}
.model-selector .actions .icon-btn {
  width: 36px; height: 32px; border-radius: 8px;
  background: rgba(255,255,255,.06); color: rgba(255,255,255,.7);
  display: inline-flex; align-items: center; justify-content: center; transition: 120ms;
}
.model-selector .actions .icon-btn:hover { background: rgba(255,255,255,.12); color: white; }

/* ── DOTS ── */
.model-dots { display: flex; gap: 4px; justify-content: center; }
.model-dots .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,.15); cursor: pointer; transition: 120ms;
}
.model-dots .dot.active { background: var(--hk-accent); width: 18px; border-radius: 3px; }
.model-dots .dot:hover { background: rgba(255,255,255,.4); }

/* ── GEAR BUTTON (top-right of model-selector) ── */
.model-selector .gear-btn {
  width: 28px; height: 28px; border-radius: 7px; border: none; cursor: pointer;
  background: rgba(255,255,255,.07); color: rgba(255,255,255,.55);
  display: inline-flex; align-items: center; justify-content: center; transition: 120ms;
  flex-shrink: 0;
}
.model-selector .gear-btn:hover,
.model-selector .gear-btn.open { background: rgba(212,175,55,.2); color: var(--hk-accent); }

/* ── MODEL PICKER (in-block dropdown) ── */
.model-picker {
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 8px;
}
.model-picker .picker-header {
  font-size: 9px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: rgba(255,255,255,.35);
  margin-bottom: 6px;
}
.model-picker .picker-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 7px; cursor: pointer;
  transition: 100ms; margin-bottom: 2px;
}
.model-picker .picker-row:hover { background: rgba(255,255,255,.06); }
.model-picker .picker-row.active { background: rgba(212,175,55,.12); }
.model-picker .picker-letter {
  width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0;
  background: rgba(255,255,255,.1); color: rgba(255,255,255,.85);
  font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.model-picker .picker-row.active .picker-letter { background: var(--hk-accent); color: #1a2a1a; }
.model-picker .picker-info { flex: 1; min-width: 0; }
.model-picker .picker-name {
  font-size: 11px; font-weight: 600; color: rgba(255,255,255,.85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.model-picker .picker-col {
  font-size: 9px; color: rgba(255,255,255,.35); margin-top: 1px;
}
.model-picker .picker-btns {
  display: flex; gap: 3px; flex-shrink: 0;
}
.model-picker .picker-btns button {
  width: 22px; height: 22px; border-radius: 5px; border: none; cursor: pointer;
  background: transparent; color: rgba(255,255,255,.35);
  display: inline-flex; align-items: center; justify-content: center; transition: 100ms;
}
.model-picker .picker-btns button:hover { background: rgba(255,255,255,.1); color: rgba(255,255,255,.8); }
.model-picker .picker-btns button.danger:hover { background: rgba(220,50,50,.18); color: #f87171; }
.model-picker .picker-add-btn {
  width: 100%; margin-top: 6px; padding: 6px 0;
  border: 1px dashed rgba(212,175,55,.35); border-radius: 7px;
  background: transparent; color: var(--hk-accent); font-size: 10px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: 120ms; letter-spacing: .03em;
}
.model-picker .picker-add-btn:hover { background: rgba(212,175,55,.1); border-color: rgba(212,175,55,.6); }

/* ── MODAL CLOSE BUTTON ── */
.modal-close-btn {
  position: absolute; top: 1rem; right: 1rem;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.08); border: none;
  color: rgba(255,255,255,.5); font-size: 1rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: 120ms;
}
.modal-close-btn:hover { background: rgba(255,255,255,.15); color: white; }

/* ── MODELO FORM ROWS (select left, image right) ── */
.mf-row {
  display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.6rem;
}
.mf-select { flex: 1; min-width: 0; padding: 0.45rem; font-size: 0.72rem; }
.mf-img-wrap {
  width: 48px; height: 48px; border-radius: 8px; flex-shrink: 0;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.07);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.mf-img {
  width: 48px; height: 48px; border-radius: 8px; object-fit: cover;
  flex-shrink: 0; display: block;
}

