/* VOLTECH — Identidad visual: negro #0A0A0A, azul eléctrico #0283EB, blanco. Dark-first. */
:root {
  --bg: #0A0A0A;
  --panel: #141414;
  --panel-2: #1a1a1a;
  --panel-3: #202020;
  --border: #2a2a2a;
  --border-2: #363636;
  --blue: #0283EB;
  --blue-hover: #1f97ff;
  --blue-dim: rgba(2,131,235,0.12);
  --text: #ffffff;
  --muted: #8b8f96;
  --muted-2: #6b7178;
  --green: #21c07a;
  --amber: #f5a623;
  --red: #f2555a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; }
/* Tamaño base de todos los íconos SVG (evita que se rendericen gigantes) */
svg { width: 16px; height: 16px; flex: none; vertical-align: middle; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2c2c2c; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 600px at 70% -10%, rgba(2,131,235,.10), transparent 60%), var(--bg); }
.login-card { width: 380px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 36px 32px; box-shadow: var(--shadow); }
.login-card img { height: 54px; display: block; margin: 0 auto 8px; }
.login-card h1 { font-size: 15px; text-align: center; font-weight: 500; color: var(--muted); margin: 0 0 26px; letter-spacing:.3px; }
.login-err { background: rgba(242,85,90,.12); border:1px solid rgba(242,85,90,.35); color:#ff9ea1;
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: #0d0d0d; border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand img { height: 30px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: 13.5px; transition: .12s; }
.nav a svg { width: 18px; height: 18px; opacity: .85; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--blue-dim); color: #fff; }
.nav a.active svg { color: var(--blue); opacity: 1; }
.nav .soon { margin-left: auto; font-size: 9px; color: var(--muted-2); border:1px solid var(--border-2); padding: 1px 5px; border-radius: 6px; }
.sidebar-foot { margin-top: auto; font-size: 11px; color: var(--muted-2); padding: 12px 10px 2px; border-top:1px solid var(--border); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 60px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  gap: 16px; padding: 0 24px; position: sticky; top: 0; background: rgba(10,10,10,.85); backdrop-filter: blur(8px); z-index: 20; }
.topbar h2 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar .spacer { flex: 1; }
.dollar-chip { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 20px; font-size: 12.5px; }
.dollar-chip b { color: var(--blue); font-size: 13px; }
.dollar-chip .t { color: var(--muted); }
.icon-btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { border-color: var(--blue); color: var(--blue); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color:#fff; display:grid; place-items:center; font-weight:600; font-size:13px; cursor:pointer; }
.content { padding: 24px; max-width: 1400px; width: 100%; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border-2); padding: 9px 15px; border-radius: var(--radius-sm); font-size: 13.5px;
  font-weight: 500; cursor: pointer; transition: .12s; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-hover); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff9ea1; border-color: rgba(242,85,90,.4); }
.btn.danger:hover { background: rgba(242,85,90,.12); }
.voided-row td { opacity: .5; }
.voided-row:hover td { opacity: .75; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.chk input { width: auto; margin: 0; cursor: pointer; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Inputs ---------- */
label.fld { display: block; margin-bottom: 12px; }
label.fld > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea { width: 100%; background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text);
  padding: 9px 11px; border-radius: var(--radius-sm); font-size: 13.5px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; min-height: 64px; }
/* Campo de contraseña con botón de ver/ocultar */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 40px; }
.pw-toggle { position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 32px; height: 32px; padding: 0; background: none; border: 0; cursor: pointer;
  color: var(--muted); display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); }
.pw-toggle:hover { color: var(--blue); }
.pw-toggle:focus { border-color: transparent; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* ---------- Cards / panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-pad { padding: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi .l { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.kpi .s { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }
.kpi.accent .v { color: var(--blue); }
.kpi.good .v { color: var(--green); }
.kpi.bad .v { color: var(--red); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted);
  padding: 11px 14px; border-bottom: 1px solid var(--border); font-weight: 600; white-space: nowrap; cursor: default; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
td { padding: 11px 14px; border-bottom: 1px solid #1c1c1c; font-size: 13.5px; }
tr:hover td { background: var(--panel-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; color: var(--muted); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search { position: relative; }
.search input { padding-left: 38px; height: 42px; background: #242424; border: 1px solid #4a4a4a; color: #fff; font-size: 14px; }
.search input::placeholder { color: #b7bcc4; opacity: 1; }
.search input:hover { border-color: #5c5c5c; }
.search input:focus { border-color: var(--blue); background: #2b2b2b; box-shadow: 0 0 0 3px var(--blue-dim); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #c4c9d0; pointer-events: none; }
.search input:focus + svg, .search:focus-within svg { color: var(--blue); }
.toolbar .search { flex: 1; min-width: 220px; }
.toolbar select { width: auto; min-width: 130px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-head h3 { margin: 0; font-size: 20px; font-weight: 700; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 10px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.badge.new { background: rgba(2,131,235,.15); color: #6cc0ff; }
.badge.up { background: rgba(245,166,35,.14); color: #ffce7a; }
.badge.same { background: #202020; color: var(--muted); }
.badge.off { background: rgba(242,85,90,.14); color: #ff9ea1; }
.badge.ok { background: rgba(33,192,122,.14); color: #74e3ad; }
.st { display:inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background:#202020; color:var(--muted); }
.st.b { background: rgba(2,131,235,.15); color:#6cc0ff; }
.st.g { background: rgba(33,192,122,.14); color:#74e3ad; }
.st.a { background: rgba(245,166,35,.14); color:#ffce7a; }
.st.r { background: rgba(242,85,90,.14); color:#ff9ea1; }

/* ---------- Modal / drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; width: 520px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal.wide { width: 920px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top:0; background: var(--panel); }
.modal-head h4 { margin: 0; font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--panel); }
.close-x { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }

/* ---------- Toast ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--panel-3); border: 1px solid var(--border-2); border-left: 3px solid var(--blue);
  padding: 12px 16px; border-radius: 8px; font-size: 13.5px; box-shadow: var(--shadow); min-width: 240px; animation: slidein .2s; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

/* ---------- Quote builder ---------- */
.builder { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.pick-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 8px; }
.pick-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-bottom: 1px solid #1c1c1c; cursor: pointer; }
.pick-item:hover { background: var(--panel-2); }
.pick-item .code { font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--blue); width: 92px; flex: none; }
.pick-item .d { flex: 1; font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-item .p { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.summary { position: sticky; top: 80px; }
.sum-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13.5px; }
.sum-row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 12px; font-size: 16px; font-weight: 700; }
.sum-row .muted { color: var(--muted); }
.internal { background: rgba(2,131,235,.06); border: 1px dashed rgba(2,131,235,.3); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 14px; }
.internal .tag { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--blue); margin-bottom: 8px; font-weight: 700; }
.warn { background: rgba(245,166,35,.1); border:1px solid rgba(245,166,35,.35); color:#ffce7a; padding: 10px 12px; border-radius: 8px; font-size: 12.5px; margin-top: 10px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; opacity: .4; margin-bottom: 12px; }
.muted { color: var(--muted); }
.spin { width: 20px; height: 20px; border: 2px solid var(--border-2); border-top-color: var(--blue); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; padding: 60px; }

/* burger y backdrop: ocultos en desktop, visibles al colapsar */
.burger { display: none; }
.sidebar-backdrop { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; z-index: 60; width: 260px; height: 100vh;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; }
  .burger { display: grid; }
  .builder { grid-template-columns: 1fr; }

  .topbar { padding: 0 14px; gap: 10px; }
  .topbar h2 { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .content { padding: 16px 14px; }

  /* apila filas (formularios y columnas de layout).
     !important para vencer estilos inline (align-items:flex-start, flex:2, width:150px, etc.)
     que si no dejaban los paneles angostos en mobile. */
  .row { flex-direction: column; gap: 12px; align-items: stretch !important; }
  .row > * { flex: 1 1 auto !important; width: 100% !important; min-width: 0 !important; }

  /* tablas más compactas para que entren mejor en pantallas chicas */
  th, td { padding: 9px 10px; }
  td { font-size: 12.5px; }

  /* encabezados de página apilados */
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-head .btn, .page-head a.btn { width: 100%; justify-content: center; }
  .page-actions { flex-wrap: wrap; }
  .page-actions > * { flex: 1 1 100%; justify-content: center; }

  /* KPIs más compactos: 2 columnas en pantallas chicas */
  .kpis { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .v { font-size: 21px; }

  .summary { position: static; }

  /* toolbar de filtros a ancho completo */
  .toolbar .search { flex: 1 1 100%; min-width: 0; }
  .toolbar select { flex: 1 1 auto; min-width: 0; }

  /* modales */
  .overlay { padding: 12px; align-items: start; }
  .modal-body { padding: 16px; }
  .modal-head { padding: 14px 16px; }
  .modal-foot { padding: 14px 16px; }
  /* botones de acción del modal grandes y fáciles de tocar */
  .modal-foot .btn { flex: 1; justify-content: center; padding: 12px 14px; }

  /* inputs a 16px: evita el zoom automático de iOS al enfocar un campo
     (la causa típica de que los modales/formularios "salten" en el celular) */
  input, select, textarea { font-size: 16px; }

  /* inputs numéricos chicos dentro de tablas (cantidades/costos) legibles */
  td input[type="number"] { min-width: 56px; }

  .dollar-chip { font-size: 11px; padding: 6px 10px; }
}

@media (max-width: 560px) {
  /* deja sólo el valor del dólar para no desbordar la topbar */
  .dollar-chip .t { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; }

  /* En celulares los modales pasan a pantalla completa (patrón "sheet"):
     mucho más cómodos que una tarjeta flotante con márgenes. */
  .overlay { padding: 0; align-items: stretch; }
  .modal, .modal.wide { width: 100%; max-width: 100%; min-height: 100vh;
    max-height: 100vh; border-radius: 0; border: none; }
  .modal-body { padding: 16px; }

  /* Tabla de ítems del cotizador → tarjetas apiladas (sin scroll horizontal).
     Cada producto se ve como una tarjeta con etiqueta:valor por campo. */
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px;
    padding: 6px 12px; background: var(--panel-2); }
  .rtable tr:hover td { background: transparent; }
  .rtable td { border: none; padding: 8px 0; display: flex; align-items: center;
    justify-content: space-between; gap: 12px; text-align: right; }
  .rtable td::before { content: attr(data-label); color: var(--muted); font-size: 12px;
    font-weight: 600; text-align: left; white-space: nowrap; }
  .rtable td.cell-block { flex-direction: column; align-items: stretch; text-align: left; gap: 3px;
    border-bottom: 1px dashed var(--border); padding-bottom: 9px; }
  .rtable td.cell-block::before { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
  .rtable td input { width: auto; max-width: 130px; text-align: right; }
  .rtable td.cell-del { padding-top: 4px; }
  .rtable td.cell-del::before { content: none; }
  .rtable td.cell-del .btn { width: 100%; justify-content: center; }
  .rtable td.empty { justify-content: center; }
  .rtable td.empty::before { content: none; }
}
