/* =========================================================
   TandilPlack — Gestión de Depósito
   Hoja de estilos: variables de color (tema oscuro rojo y
   negro), navbar, tarjetas, tablas, formularios/modales y
   los estilos responsivos al final del archivo.
========================================================= */
  :root{
    --bg:#14100D;
    --surface:#1E1712;
    --ink:#F3EBE4;
    --ink-soft:#AFA096;
    --wood:#D9463A;
    --wood-deep:#B23327;
    --wood-dark:#4A140D;
    --wood-dark-2:#6B1F16;
    --pine:#7FC28E;
    --pine-bg:#16261A;
    --amber:#D99A3E;
    --amber-bg:#2E2412;
    --rust:#E2764F;
    --rust-bg:#2E1712;
    --line:#3A2E27;
    --line-soft:#2A211B;
    --shadow: 0 1px 0 rgba(0,0,0,0.3);
    --radius: 10px;
  }

  *{box-sizing:border-box;}
  html,body{margin:0;padding:0;}
  body{
    background:var(--bg);
    color:var(--ink);
    font-family:'IBM Plex Sans', -apple-system, sans-serif;
    font-size:15px;
    line-height:1.5;
    -webkit-font-smoothing:antialiased;
  }
  h1,h2,h3{
    font-family:'Fraunces', Georgia, serif;
    margin:0;
    font-weight:500;
    letter-spacing:-0.01em;
    color:var(--ink);
  }
  .mono{ font-family:'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
  button{ font-family:inherit; cursor:pointer; }
  input{ font-family:inherit; }
  a{ color:inherit; }

  /* ---------- NAVBAR ---------- */
  .navbar{
    position:fixed; top:0; left:0; right:0; height:68px;
    background:
      repeating-linear-gradient(100deg, rgba(255,255,255,0.025) 0px, rgba(255,255,255,0.025) 1px, transparent 1px, transparent 7px),
      linear-gradient(180deg, var(--wood-dark-2), var(--wood-dark));
    display:flex; align-items:center; justify-content:space-between;
    padding:0 28px;
    z-index:100;
    box-shadow:0 1px 0 rgba(0,0,0,0.15);
  }
  .brand{ display:flex; align-items:center; gap:11px; }
  .brand-logo{ height:34px; width:auto; flex-shrink:0; display:block; }
  .brand-text{ display:flex; flex-direction:column; line-height:1.1; }
  .brand-text .name{ font-family:'Nunito', sans-serif; font-style:normal; font-weight:700; font-size:20px; color:#F5EEE1; text-transform:lowercase; }
  .brand-text .tag{ font-size:10.5px; color:#C9B79C; letter-spacing:0.03em; margin-top:2px; }

  .navlinks{ display:flex; gap:4px; }
  .navlinks button{
    background:none; border:none; color:#DCCFB9;
    font-size:14px; font-weight:500; padding:9px 16px; border-radius:7px;
    transition:background .15s, color .15s;
  }
  .navlinks button:hover{ background:rgba(255,255,255,0.06); color:#fff; }
  .navlinks button.active{ background:rgba(255,255,255,0.11); color:#fff; }

  .navlinks button:focus-visible, .nav-toggle:focus-visible{ outline:2px solid #E8B77F; outline-offset:2px; }

  .nav-right{ display:flex; align-items:center; gap:14px; }
  .nav-toggle{
    display:none; width:38px; height:38px; align-items:center; justify-content:center;
    background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.14);
    border-radius:8px; color:#F5EEE1; padding:0;
  }
  .nav-toggle:hover{ background:rgba(255,255,255,0.15); }
  .nav-toggle .icon-close{ display:none; }
  .nav-toggle[aria-expanded="true"] .icon-open{ display:none; }
  .nav-toggle[aria-expanded="true"] .icon-close{ display:block; }
  .avatar{
    width:34px; height:34px; border-radius:50%;
    background:#1A100B; color:#F5EEE1; display:flex; align-items:center; justify-content:center;
    font-family:'Fraunces',serif; font-weight:600; font-size:14px;
    border:1.5px solid rgba(255,255,255,0.3);
  }

  /* ---------- LAYOUT ---------- */
  main{ padding-top:68px; }
  .container{ max-width:1180px; margin:0 auto; padding:36px 28px 80px; }
  .section{ display:none; }
  .section.active{ display:block; animation:fade .35s ease; }
  @keyframes fade{ from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:none;} }

  .section-head{
    display:flex; justify-content:space-between; align-items:flex-end;
    margin-bottom:26px; gap:20px; flex-wrap:wrap;
  }
  .section-head h1{ font-size:30px; }
  .section-head .sub{ color:var(--ink-soft); font-size:14px; margin-top:5px; }
  .head-actions{ display:flex; gap:10px; flex-wrap:wrap; }

  /* ---------- BUTTONS ---------- */
  .btn{
    display:inline-flex; align-items:center; gap:7px;
    padding:9px 16px; border-radius:8px; font-size:13.5px; font-weight:600;
    border:1px solid transparent; transition:filter .15s, background .15s;
  }
  .btn-primary{ background:var(--wood); color:#fff; }
  .btn-primary:hover{ filter:brightness(0.94); }
  .btn-ghost{ background:transparent; color:var(--ink); border-color:var(--line); }
  .btn-ghost:hover{ background:var(--line-soft); }
  .btn-outline{ background:var(--surface); color:var(--wood-deep); border-color:var(--wood); }
  .btn-outline:hover{ background:rgba(217,70,58,0.16); }
  .btn-sm{ padding:6px 12px; font-size:12.5px; }
  .icon-btn{
    width:30px; height:30px; display:inline-flex; align-items:center; justify-content:center;
    border-radius:7px; border:1px solid var(--line); background:var(--surface); color:var(--ink-soft);
  }
  .icon-btn:hover{ background:var(--line-soft); color:var(--ink); }

  /* ---------- STAT CARDS ---------- */
  .stats{ display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:30px; }
  .stat{
    background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
    padding:16px 18px; position:relative; overflow:hidden;
  }
  .stat::before{
    content:""; position:absolute; top:0; left:0; right:0; height:3px; background:var(--accent, var(--wood));
  }
  .stat .label{ font-size:12.5px; color:var(--ink-soft); font-weight:500; }
  .stat .value{ font-family:'Fraunces', serif; font-size:28px; margin-top:6px; color:var(--ink); }
  .stat .hint{ font-size:12px; color:var(--ink-soft); margin-top:3px; }

  /* ---------- SEARCH ---------- */
  .search{
    position:relative; display:flex; align-items:center;
  }
  .search input{
    border:1px solid var(--line); background:var(--surface); border-radius:8px;
    padding:9px 12px 9px 34px; font-size:13.5px; width:230px; color:var(--ink);
    outline:none; transition:border-color .15s;
  }
  .search input:focus{ border-color:var(--wood); }
  .search svg{ position:absolute; left:11px; color:var(--ink-soft); }

  /* ---------- TOOLBAR (búsqueda + filtros) ---------- */
  .toolbar{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-bottom:14px; }
  .toolbar .search input{ width:270px; }
  .filter-select{
    appearance:none; -webkit-appearance:none; cursor:pointer;
    border:1px solid var(--line); border-radius:8px; color:var(--ink);
    padding:9px 34px 9px 12px; font-family:inherit; font-size:13.5px; outline:none;
    background:var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23AFA096' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
    transition:border-color .15s;
  }
  .filter-select:focus{ border-color:var(--wood); }
  .filter-select.active{ border-color:var(--wood); color:var(--wood); font-weight:500; background-color:rgba(217,70,58,0.16); }
  .search input:focus-visible, .filter-select:focus-visible{ outline:2px solid rgba(217,70,58,0.4); outline-offset:1px; }
  .btn[hidden]{ display:none; }
  .panel .toolbar{ margin:0; padding:12px 18px; border-bottom:1px solid var(--line); }

  /* ---------- TABLE ---------- */
  .table-wrap{
    background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
    overflow-x:auto;
  }
  table{ width:100%; border-collapse:collapse; }
  thead th{
    text-align:left; font-size:12.5px; font-weight:600; color:var(--ink-soft);
    padding:12px 16px; border-bottom:1px solid var(--line); background:#241B16;
  }
  tbody td{ padding:13px 16px; border-bottom:1px solid var(--line-soft); font-size:13.5px; }
  tbody tr:last-child td{ border-bottom:none; }
  tbody tr:hover{ background:rgba(255,255,255,0.035); }
  td.num, th.num{ text-align:right; }
  .prod-name{ font-weight:600; color:var(--ink); }
  .prod-cat{ display:block; font-size:11.5px; color:var(--ink-soft); font-weight:400; margin-top:1px; }

  .pill{
    display:inline-flex; align-items:center; gap:5px; padding:3px 10px; border-radius:20px;
    font-size:11.5px; font-weight:600;
  }
  .pill-ok{ background:var(--pine-bg); color:var(--pine); }
  .pill-bajo{ background:var(--amber-bg); color:var(--amber); }
  .pill-critico{ background:var(--rust-bg); color:var(--rust); }
  .pill::before{ content:""; width:6px; height:6px; border-radius:50%; background:currentColor; }

  .row-actions{ display:flex; gap:6px; justify-content:flex-end; }
  th.actions, td.actions{ width:1%; white-space:nowrap; }

  /* ---------- CHIPS (historial filter) ---------- */
  .chips{ display:flex; gap:8px; margin-bottom:18px; flex-wrap:wrap; }
  .chip{
    padding:7px 14px; border-radius:20px; border:1px solid var(--line); background:var(--surface);
    font-size:12.5px; font-weight:500; color:var(--ink-soft);
  }
  .chip.active{ background:var(--wood); color:#fff; border-color:var(--wood); }

  .op-tag{ display:inline-flex; align-items:center; gap:6px; font-size:12.5px; font-weight:600; padding:4px 10px 4px 8px; border-radius:7px; }
  .op-corte{ background:var(--pine-bg); color:var(--pine); }
  .op-compra{ background:#18232E; color:#8FB6E3; }
  .op-retiro{ background:var(--amber-bg); color:var(--amber); }
  .op-alta{ background:#211A2C; color:#C3A8E8; }
  .op-venta{ background:#122328; color:#7ED2DB; }
  .op-mod{ background:var(--line-soft); color:var(--ink-soft); }
  .op-baja{ background:var(--rust-bg); color:var(--rust); }
  .op-dot{ width:6px; height:6px; border-radius:50%; background:currentColor; }

  /* ---------- SALDO / DESTINO ---------- */
  .saldo{ font-weight:600; }
  .saldo.cero{ color:var(--pine); }
  .saldo.pendiente{ color:var(--wood); }

  /* ---------- COMPRAS layout ---------- */
  .compras-grid{ display:grid; grid-template-columns:1fr; gap:20px; align-items:start; }
  .panel{ background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); overflow-x:auto; }
  .panel-head{ padding:16px 18px 14px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:center; }
  .panel-head h2{ font-size:17px; }
  .panel-head .count{ font-size:12px; color:var(--ink-soft); }
  .compras-actions{ display:flex; justify-content:flex-end; }

  /* ---------- MODAL ---------- */
  .overlay{
    position:fixed; inset:0; background:rgba(0,0,0,0.65); display:none;
    align-items:center; justify-content:center; z-index:200; padding:20px;
  }
  .overlay.open{ display:flex; }
  .modal{
    background:var(--surface); border:1px solid var(--line); border-radius:14px; width:100%; max-width:460px;
    box-shadow:0 20px 60px rgba(0,0,0,0.45); overflow:hidden;
    animation:pop .18s ease;
  }
  @keyframes pop{ from{ transform:scale(.97); opacity:0; } to{ transform:none; opacity:1; } }
  .modal-head{
    padding:18px 22px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:center;
    background:#241B16;
  }
  .modal-head h3{ font-size:18px; }
  .modal-close{ background:none; border:none; color:var(--ink-soft); padding:4px; border-radius:6px; }
  .modal-close:hover{ background:var(--line-soft); }
  .modal-body{ padding:20px 22px; }
  .modal-foot{ padding:16px 22px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:10px; }

  .field{ margin-bottom:14px; }
  .field label{ display:block; font-size:12.5px; font-weight:600; color:var(--ink-soft); margin-bottom:6px; }
  .field input, .field select{
    width:100%; padding:9px 11px; border:1px solid var(--line); border-radius:7px;
    font-size:13.5px; color:var(--ink); background:var(--surface); outline:none;
  }
  .field input:focus, .field select:focus{ border-color:var(--wood); }
  .field-row{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }

  .toggle-group{ display:flex; gap:8px; }
  .toggle{
    flex:1; padding:9px; text-align:center; border:1px solid var(--line); border-radius:7px;
    font-size:13px; font-weight:500; color:var(--ink-soft); background:var(--surface);
  }
  .toggle.selected{ border-color:var(--wood); background:rgba(217,70,58,0.16); color:var(--wood); font-weight:600; }

  /* ---------- TOAST ---------- */
  .toast{
    position:fixed; bottom:26px; left:50%; transform:translateX(-50%) translateY(10px);
    background:var(--wood-deep); color:#F5EEE1; padding:12px 20px; border-radius:9px; border:1px solid rgba(255,255,255,0.08);
    font-size:13.5px; font-weight:500; display:flex; align-items:center; gap:9px;
    box-shadow:0 10px 30px rgba(0,0,0,0.2); opacity:0; pointer-events:none; transition:all .25s ease; z-index:300;
  }
  .toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

  @keyframes drop{ from{ opacity:0; transform:translateY(-6px); } to{ opacity:1; transform:none; } }

  /* navbar compacto: los links pasan a un menú desplegable */
  @media (max-width: 1040px){
    .nav-toggle{ display:inline-flex; }
    .navlinks{
      display:none; position:fixed; top:68px; left:0; right:0;
      flex-direction:column; gap:2px; padding:10px 16px 16px;
      max-height:calc(100vh - 68px); overflow-y:auto;
      background:linear-gradient(180deg, var(--wood-dark), var(--wood-dark-2));
      border-top:1px solid rgba(255,255,255,0.08);
      box-shadow:0 16px 32px rgba(20,14,11,0.32);
    }
    .navlinks.open{ display:flex; animation:drop .18s ease; }
    .navlinks button{ text-align:left; padding:13px 14px; font-size:15px; }
  }

  @media (max-width: 720px){
    .toolbar .search{ flex:1 1 100%; }
    .toolbar .search input{ width:100%; }
    .filter-select{ flex:1 1 auto; }
    .stats{ grid-template-columns:repeat(2,1fr); }
    .section-head{ flex-direction:column; align-items:flex-start; }
  }

  @media (max-width: 480px){
    .navbar{ padding:0 16px; }
    .container{ padding:26px 16px 60px; }
    .section-head h1{ font-size:26px; }
  }

  @media (prefers-reduced-motion: reduce){
    .navlinks.open, .section.active{ animation:none; }
  }


/* ---------- CLIENTE ---------- */
tr.row-click{ cursor:pointer; }
.row-click-arrow{ color:var(--ink-soft); }
tr.row-click:hover .row-click-arrow{ color:var(--wood); }

.points-badge{
  display:inline-flex; align-items:center;
  padding:3px 10px; border-radius:999px;
  background:var(--pine-bg); color:var(--pine);
  font-family:'IBM Plex Mono', monospace; font-size:12.5px; font-weight:600;
}

.modal-lg{ max-width:620px; }

.cliente-summary{
  display:flex; gap:28px; margin-bottom:18px;
  padding-bottom:16px; border-bottom:1px solid var(--line);
}
.cliente-summary > div{ display:flex; flex-direction:column; gap:4px; }
.cliente-summary-label{ font-size:12px; color:var(--ink-soft); }

.venta-card{
  border:1px solid var(--line); border-radius:10px;
  overflow:hidden; margin-bottom:12px;
}
.venta-card:last-child{ margin-bottom:0; }
.venta-card-head{
  display:flex; align-items:center; gap:12px;
  padding:10px 14px; background:#241B16;
  font-size:13px;
}
.venta-card-head .venta-obra{ color:var(--ink-soft); flex:1; }
.venta-card-head .venta-total{ color:var(--wood); font-weight:600; }

table.venta-items{ width:100%; border-collapse:collapse; font-size:13px; }
table.venta-items th{
  text-align:left; font-weight:500; color:var(--ink-soft);
  padding:8px 14px; border-bottom:1px solid var(--line);
}
table.venta-items td{ padding:8px 14px; border-bottom:1px solid var(--line-soft); }
table.venta-items tr:last-child td{ border-bottom:none; }
table.venta-items th.num, table.venta-items td.num{ text-align:right; }

.modal { display: flex; flex-direction: column; max-height: 90vh; max-height: 90dvh; }
.modal-head, .modal-foot { flex-shrink: 0; }
.modal-body { overflow-y: auto; min-height: 0; }

.modal.modal-ancho { width: min(980px, 96vw); max-width: 96vw; }

.vi-cabecera, .vi {
  display: grid;
  grid-template-columns: minmax(0, 3fr) repeat(3, minmax(0, 1fr)) 34px;
  gap: 8px;
  align-items: center;
}
.vi-cabecera { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; padding: 0 2px; }
.vi { margin-bottom: 8px; }
.vi .vi-f { display: flex; flex-direction: column; gap: 4px; margin: 0; min-width: 0; }
.vi .vi-f input { width: 100%; min-width: 0; }
.vi-lbl { display: none; font-size: 12px; color: var(--ink-soft); }

@media (max-width: 700px) {
  .vi-cabecera { display: none; }
  .vi {
    grid-template-columns: 1fr 1fr 1fr 34px;
    align-items: end;
    padding: 8px;
    border: 1px solid var(--line, #ddd);
    border-radius: 8px;
  }
  .vi .vi-f:first-child { grid-column: 1 / -1; }
  .vi-lbl { display: block; }
}

/* resaltado de todas las filas de una misma venta */
/* en Ventas el resaltado lo maneja solo el grupo (ver app.js) */
/* Ventas: el resaltado lo maneja solo el grupo (ver app.js) */
#ventas-tbody tr:hover { background: transparent; }
#ventas-tbody tr.grupo-hover td { background: rgba(255,255,255,0.035); }

.venta-cabecera { display: grid; grid-template-columns: 2fr 2fr 1fr; gap: 14px; }
.venta-cabecera .field { min-width: 0; }
@media (max-width: 700px) {
  .venta-cabecera { grid-template-columns: 1fr; gap: 0; }
}

/* ---------- Compras ---------- */
.btn-grande { width: 100%; flex-direction: column; gap: 4px; padding: 20px 24px; font-size: 17px; }
.btn-grande span { font-size: 13px; font-weight: 400; opacity: .8; }

.compra-cabecera { display: grid; grid-template-columns: 3fr 1fr; gap: 14px; }
.compra-cabecera .field { min-width: 0; }

.ci-cabecera, .ci {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 1.2fr) minmax(0, 1.4fr) 34px;
  gap: 8px;
  align-items: center;
}
.ci-cabecera { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; padding: 0 2px; }
.ci { margin-bottom: 8px; }
.ci .ci-f { display: flex; flex-direction: column; gap: 4px; margin: 0; min-width: 0; }
.ci .ci-f input { width: 100%; min-width: 0; }

@media (max-width: 700px) {
  .compra-cabecera { grid-template-columns: 1fr; gap: 0; }
  .ci-cabecera { display: none; }
  .ci {
    grid-template-columns: 1fr 1fr 34px;
    align-items: end;
    padding: 8px;
    border: 1px solid var(--line, #ddd);
    border-radius: 8px;
  }
  .ci .ci-f:first-child { grid-column: 1 / -1; }
}

.ri-cabecera, .ri {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
}
.ri-cabecera { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; padding: 0 2px; }
.ri { margin-bottom: 8px; }
.ri .ri-f { display: flex; flex-direction: column; gap: 4px; margin: 0; min-width: 0; }
.ri .ri-f input { width: 100%; min-width: 0; }
@media (max-width: 700px) { .ri-cabecera { display: none; } }

/* resaltado por grupo en Ingresos (igual que en Ventas) */
#ingresos-tbody tr:hover { background: transparent; }
#ingresos-tbody tr.grupo-hover td { background: rgba(255,255,255,0.035); }
#retiro-tbody tr:hover { background: transparent; }
#retiro-tbody tr.grupo-hover td { background: rgba(255,255,255,0.035); }
#cortar-tbody tr:hover { background: transparent; }
#cortar-tbody tr.grupo-hover td { background: rgba(255,255,255,0.035); }
#cortar-tbody td.acciones-corte { text-align: center; white-space: nowrap; }

/* encabezado fijo en la tabla de la sugerencia */
#modal-sugerencia thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
/* =========================================
   MENÚ DE USUARIO (DROPDOWN)
   ========================================= */
.user-dropdown-container {
  position: relative;
  display: inline-block;
}

.avatar {
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s;
}

.avatar:hover {
  transform: scale(1.05);
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 45px;
  background-color: #ffffff;
  min-width: 180px;
  box-shadow: 0px 8px 16px rgba(0,0,0,0.15);
  border-radius: 8px;
  overflow: hidden;
  z-index: 1000;
  border: 1px solid #eee;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  padding: 12px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: #333;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid #f5f5f5;
}

.dropdown-item:hover {
  background-color: #f9f9f9;
}

.dropdown-item.danger {
  color: #d9534f;
  border-bottom: none;
}

.hidden {
  display: none !important;
}