* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --teal: #30a5ae;
  --purple: #7c5cfc;
  --purple-2: #9a5fe2;
  --mint: #6fc7ad;
  --dark: #0f1414;
  --sidebar-bg: #14141f;
  --sidebar-width: 240px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f2f5;
  color: var(--dark);
}

.hidden { display: none !important; }

/* LOGIN */
.login-page-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1414 0%, #1a2a2a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  max-width: 400px;
  width: 90%;
  background: white;
  border-radius: 20px;
  padding: 44px 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}
.login-logo { width: 150px; margin-bottom: 20px; }
.login-box h1 { font-size: 20px; color: var(--dark); margin-bottom: 2px; font-weight: 700; }
.subtitle { color: var(--purple); margin-bottom: 28px; font-weight: 600; font-size: 13px; letter-spacing: 0.5px; text-transform: uppercase; }
.form-group { text-align: left; margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #555; }
.form-group input { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 10px; font-size: 15px; transition: border 0.2s; }
.form-group input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(48,165,174,0.1); }
.error-msg { color: #e74c3c; font-size: 13px; margin-top: 10px; min-height: 18px; }
.dev-credit { font-size: 11px; color: #bbb; margin-top: 20px; }

/* BUTTONS */
.btn { padding: 10px 18px; border: none; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; transition: all 0.2s; }
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--purple), var(--purple-2)); color: white; }
.btn-secondary { background: #f0f2f5; color: #333; }
.btn-success { background: #2ecc71; color: white; }
.btn-danger { background: #e74c3c; color: white; }
.btn-purple { background: var(--purple); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; padding: 13px; font-size: 16px; }

/* SIDEBAR */
.sidebar {
  background: var(--sidebar-bg);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  width: var(--sidebar-width);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  box-shadow: 2px 0 16px rgba(0,0,0,0.25);
  overflow-y: auto;
}
.nav-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 22px; }
.nav-brand img { height: 32px; }
.nav-brand span { font-weight: 700; font-size: 16px; color: white; }
.nav-links { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-group-title { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: rgba(255,255,255,0.4); padding: 14px 10px 4px; }
.nav-group-title:first-child { padding-top: 2px; }
.nav-footer { display: flex; flex-direction: column; gap: 4px; padding-top: 14px; margin-top: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.nav-btn {
  background: none; border: none; color: #9a9aac; cursor: pointer;
  padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  transition: all 0.2s;
}
.nav-icon { font-size: 16px; line-height: 1; width: 20px; text-align: center; flex-shrink: 0; }
.nav-btn:hover { background: rgba(124,92,252,0.14); color: white; }
.nav-btn.active { background: linear-gradient(135deg, var(--purple), var(--purple-2)); color: white; box-shadow: 0 4px 14px rgba(124,92,252,0.35); }
#nav-user { color: #7a7a8c; font-size: 12px; padding: 6px 14px 2px; }

/* WATERMARK */
#app-page {
  min-height: 100vh;
  background-image: url('logo.png');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 400px;
  background-attachment: fixed;
  position: relative;
}
#app-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(240,242,245,0.92);
  z-index: 0;
  pointer-events: none;
}
#app-page .sidebar { position: fixed; z-index: 100; }
#app-page .container { position: relative; z-index: 1; }

/* CONTAINER */
.container { max-width: 1200px; margin: 0 auto; margin-left: calc(var(--sidebar-width) + 16px); padding: 24px 16px 24px; }

/* TAB HEADER */
.tab-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.tab-header h2 { font-size: 20px; font-weight: 700; color: var(--dark); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filter-input { padding: 8px 14px; border: 1px solid #ddd; border-radius: 10px; font-size: 14px; background: white; }
.filter-input:focus { outline: none; border-color: var(--teal); }

/* CARDS */
.cards-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

.card {
  background: white;
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border-left: 5px solid #ddd;
  transition: box-shadow 0.2s;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}
.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.card.estado-activo { border-left-color: var(--teal); }
.card.estado-recompro { border-left-color: #2ecc71; }
.card.estado-no_quiere { border-left-color: #e74c3c; }
.card.estado-suspendido { border-left-color: #95a5a6; }

.card-left { display: flex; flex-direction: column; }
.card-right { display: flex; flex-direction: column; border-left: 1px solid #f0f0f0; padding-left: 24px; }
.card-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; color: var(--dark); }
.card-sub { font-size: 13px; color: var(--teal); margin-bottom: 10px; font-weight: 600; }
.card-info { font-size: 13px; color: #666; margin-bottom: 4px; }
.card-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; grid-column: 1 / -1; border-top: 1px solid #f5f5f5; padding-top: 14px; }
.card-mensaje-label { font-size: 12px; font-weight: 700; color: #aaa; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.card-mensaje-texto { font-size: 13px; color: #444; line-height: 1.6; background: #f8f9fa; padding: 12px; border-radius: 8px; border: 1px solid #eee; white-space: pre-wrap; flex: 1; max-height: 160px; overflow-y: auto; }

/* BADGE */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.badge-activo { background: rgba(48,165,174,0.12); color: var(--teal); }
.badge-recompro { background: #d5f5e3; color: #1e8449; }
.badge-no_quiere { background: #fdecea; color: #c0392b; }
.badge-suspendido { background: #f2f3f4; color: #7f8c8d; }

/* TEMPLATES */
.template-card { background: white; border-radius: 14px; padding: 18px; margin-bottom: 14px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.template-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.template-meta { font-size: 13px; color: #888; }
.template-texto { font-size: 14px; line-height: 1.7; background: #f8f9fa; padding: 14px; border-radius: 10px; border: 1px solid #eee; white-space: pre-wrap; }
.template-textarea { width: 100%; font-size: 14px; line-height: 1.6; padding: 12px; border: 1px solid #ddd; border-radius: 10px; resize: vertical; min-height: 100px; font-family: inherit; }
.template-textarea:focus { outline: none; border-color: var(--teal); }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal-content { background: white; border-radius: 16px; width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid #eee; }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #999; }
#modal-body { padding: 20px 24px 24px; }
#modal-body .form-group { margin-bottom: 14px; }
#modal-body input, #modal-body select { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 10px; font-size: 14px; }
#modal-body input:focus, #modal-body select:focus { outline: none; border-color: var(--teal); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* FILTRO CHECKBOX */
.filter-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #555; cursor: pointer; background: white; border: 1px solid #ddd; border-radius: 10px; padding: 8px 12px; }
.filter-check input { cursor: pointer; }

/* SEMAFORO */
.sem-badge { display: inline-flex; align-items: center; gap: 4px; }
.card.sem-rojo { border-left-color: #e74c3c; }
.card.sem-amarillo { border-left-color: #f1c40f; }
.card.sem-verde { border-left-color: #2ecc71; }
.card.sem-gris { border-left-color: #bbb; }
.sem-badge.sem-rojo { background: #fdecea; color: #c0392b; }
.sem-badge.sem-amarillo { background: #fef9e7; color: #b7950b; }
.sem-badge.sem-verde { background: #d5f5e3; color: #1e8449; }
.sem-badge.sem-gris { background: #f2f3f4; color: #7f8c8d; }

/* CONFIG */
.config-row { background: white; border-radius: 12px; padding: 16px 20px; margin-bottom: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: center; }
.config-label { display: flex; flex-direction: column; gap: 4px; }
.config-label code { background: #f0f2f5; padding: 3px 8px; border-radius: 6px; font-size: 13px; color: var(--teal); font-weight: 700; width: fit-content; }
.config-label small { color: #888; font-size: 12px; }
.config-input { width: 100%; }
@media (max-width: 600px) { .config-row { grid-template-columns: 1fr; } }

/* ORDENES DE VENTA */
.orden-card { background: white; border-radius: 14px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); margin-bottom: 20px; overflow: hidden; }
.orden-card-header { background: linear-gradient(135deg, var(--teal), var(--purple)); padding: 18px 20px; color: white; display: flex; align-items: center; gap: 12px; }
.orden-card-header img { height: 32px; filter: brightness(0) invert(1); }
.orden-card-header h2 { font-size: 17px; font-weight: 700; margin: 0; }
.orden-card-body { padding: 20px; }
.orden-section-title { font-size: 12px; font-weight: 700; color: var(--teal); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.orden-total-banner { background: linear-gradient(135deg, var(--purple), var(--purple-2)); color: white; padding: 14px 20px; border-radius: 12px; text-align: right; box-shadow: 0 2px 12px rgba(124,92,252,0.3); }
.orden-total-banner span { font-size: 20px; font-weight: 700; }

/* BANNER HOY */
.hoy-banner { background: linear-gradient(135deg, var(--purple), var(--purple-2)); color: white; padding: 14px 20px; border-radius: 12px; margin-bottom: 16px; font-size: 15px; box-shadow: 0 2px 12px rgba(124,92,252,0.3); }
.hoy-banner:empty { display: none; }

/* EMPTY */
.empty-state { text-align: center; padding: 60px 20px; color: #bbb; }

/* PRODUCTOS TABLE */
.productos-table { width: 100%; border-collapse: collapse; background: white; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.productos-table thead { background: var(--dark); color: white; }
.productos-table th { padding: 14px 16px; text-align: left; font-size: 13px; font-weight: 600; }
.productos-table td { padding: 14px 16px; border-bottom: 1px solid #f0f0f0; font-size: 14px; vertical-align: middle; }
.productos-table tr:last-child td { border-bottom: none; }
.productos-table tr:hover td { background: #f8f9fa; }
.odoo-name { background: #f0f2f5; padding: 4px 8px; border-radius: 6px; font-size: 12px; font-family: monospace; color: #333; }

/* VENDEDORA */
.vendedora-card { background: white; border-radius: 14px; padding: 18px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.vendedora-inactive { opacity: 0.5; }

/* ENVÍOS MANUALES */
.envio-cliente-row {
  background: white; border-radius: 10px; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06); margin-bottom: 8px;
}
.envio-cliente-row:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.1); }
.envio-cliente-info { flex: 1; min-width: 0; }
.envio-cliente-nombre { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.envio-cliente-sub { font-size: 12px; color: #888; margin-top: 2px; }
.envio-sem { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.envio-sem.rojo { background: #e74c3c; }
.envio-sem.amarillo { background: #f1c40f; }
.envio-sem.verde { background: #2ecc71; }
.envio-seleccionado-item {
  display: flex; align-items: center; justify-content: space-between;
  background: #f8f9fa; border-radius: 8px; padding: 8px 12px; font-size: 13px;
}
.envio-seleccionado-item button { background: none; border: none; color: #e74c3c; cursor: pointer; font-size: 16px; padding: 0 4px; }

@media (max-width: 900px) { #tab-envios > div { grid-template-columns: 1fr !important; } }
@media (max-width: 780px) {
  .sidebar, #app-page .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .nav-brand { padding: 6px 10px; }
  .nav-links, .nav-footer { flex-direction: row; flex-wrap: wrap; border-top: none; margin-top: 0; padding-top: 0; }
  .nav-group-title { width: 100%; padding: 8px 4px 2px; }
  .container { margin-left: auto; padding-top: 24px; }
}
@media (max-width: 600px) {
  .cards-grid { grid-template-columns: 1fr; }
  .tab-header { flex-direction: column; align-items: flex-start; }
  .login-box { padding: 32px 24px 24px; }
}
