@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --bg:       #0D1117;
  --surface:  #161B22;
  --border:   #21262D;
  --text:     #E6EDF3;
  --muted:    #7D8590;
  --accent:   #2F81F7;
  --green:    #3FB950;
  --red:      #F85149;
  --orange:   #D29922;
  --purple:   #A371F7;
  --surface2: #1C2128;
}

*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;font-family:'IBM Plex Sans',sans-serif;background:var(--bg);color:var(--text);font-size:13px}
::-webkit-scrollbar{width:5px;height:5px}
::-webkit-scrollbar-track{background:var(--bg)}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}

/* ── Loading ── */
#loading{
  position:fixed;inset:0;
  background:rgba(13,17,23,0.92);
  backdrop-filter:blur(6px);
  display:flex;flex-direction:column;
  align-items:center;justify-content:center;
  gap:16px;z-index:9999;
  transition:opacity .2s;
}
#loading-monkey{
  animation:monkeyBob 2.4s ease-in-out infinite;
}
@keyframes monkeyBob{
  0%,100%{transform:translateY(0)}
  50%{transform:translateY(-6px)}
}
#loading-dots span{
  display:inline-block;
  width:6px;height:6px;
  border-radius:50%;
  background:var(--accent);
  margin:0 3px;
  animation:dotBounce 1.2s ease-in-out infinite;
}
#loading-dots span:nth-child(2){animation-delay:.2s}
#loading-dots span:nth-child(3){animation-delay:.4s}
@keyframes dotBounce{
  0%,80%,100%{transform:translateY(0);opacity:.4}
  40%{transform:translateY(-8px);opacity:1}
}
.spin{width:36px;height:36px;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ── Login ── */
#loginWrap{display:none;position:fixed;inset:0;background:var(--bg);align-items:center;justify-content:center}
.login-card{background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:40px;width:360px;max-width:94vw}
.login-logo{font-family:'IBM Plex Mono',monospace;font-size:22px;font-weight:600;color:var(--accent);letter-spacing:-.5px;margin-bottom:4px}
.login-sub{color:var(--muted);font-size:12px;margin-bottom:28px}
.field{width:100%;padding:9px 12px;background:var(--bg);border:1px solid var(--border);border-radius:7px;color:var(--text);font-size:13px;font-family:inherit;transition:border-color .15s;margin-bottom:10px}
.field:focus{outline:none;border-color:var(--accent)}
.btn-login{width:100%;padding:10px;background:var(--accent);border:none;border-radius:7px;color:#fff;font-size:13px;font-weight:600;cursor:pointer;font-family:inherit;transition:opacity .15s}
.btn-login:hover{opacity:.85}
.login-err{color:var(--red);font-size:11px;margin-top:8px;display:none}

/* ── Layout ── */
#app{height:100vh;flex-direction:column}
.topbar{height:48px;border-bottom:1px solid var(--border);display:flex;align-items:center;padding:0 16px;gap:12px;flex-shrink:0;background:var(--surface)}
.topbar-logo{font-family:'IBM Plex Mono',monospace;font-weight:600;font-size:14px;color:var(--accent);letter-spacing:-.3px}
.topbar-sep{width:1px;height:20px;background:var(--border)}
.topbar-co{font-size:12px;color:var(--muted)}
.topbar-user{margin-left:auto;display:flex;align-items:center;gap:10px;font-size:12px;color:var(--muted)}
.topbar-user span{color:var(--text)}
.btn-sm{padding:4px 10px;border:1px solid var(--border);border-radius:5px;background:none;color:var(--muted);font-size:11px;cursor:pointer;font-family:inherit;transition:all .15s}
.btn-sm:hover{border-color:var(--accent);color:var(--accent)}

.body{display:flex;flex:1;overflow:hidden}

/* ── Sidebar ── */
.sidebar{width:192px;border-right:1px solid var(--border);display:flex;flex-direction:column;overflow-y:auto;flex-shrink:0;background:var(--surface)}
.nav-sect{padding:16px 12px 4px;font-size:10px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}
.nav-btn{display:flex;align-items:center;gap:8px;width:100%;padding:7px 12px;border:none;background:none;color:var(--muted);font-size:12px;font-family:inherit;cursor:pointer;text-align:left;border-radius:0;transition:all .12s}
.nav-btn:hover{background:var(--border);color:var(--text)}
.nav-btn.on{background:#1F3A5A;color:var(--accent);font-weight:600}
.nav-icon{font-size:14px;width:18px;text-align:center;flex-shrink:0}

/* ── Period selector ── */
.period-bar{padding:8px 16px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:10px;background:var(--surface);flex-shrink:0}
.period-sel{padding:4px 8px;background:var(--bg);border:1px solid var(--border);border-radius:5px;color:var(--text);font-size:12px;font-family:inherit;cursor:pointer}
.period-sel:focus{outline:none;border-color:var(--accent)}

/* ── Content ── */
.content{flex:1;overflow-y:auto;padding:20px}

/* ── Cards ── */
.card{background:var(--surface);border:1px solid var(--border);border-radius:8px;margin-bottom:14px;overflow:hidden}
.card-hdr{display:flex;justify-content:space-between;align-items:center;padding:11px 16px;border-bottom:1px solid var(--border)}
.card-hdr-title{font-weight:600;font-size:13px}
.card-body{padding:16px}

/* ── KPI grid ── */
.kpi-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin-bottom:14px}
.kpi{background:var(--surface);border:1px solid var(--border);border-radius:8px;padding:14px 16px}
.kpi-l{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin-bottom:5px}
.kpi-v{font-family:'IBM Plex Mono',monospace;font-size:20px;font-weight:600}
.kpi-s{font-size:10px;color:var(--muted);margin-top:3px}

/* ── Table ── */
table{width:100%;border-collapse:collapse}
th{padding:7px 12px;text-align:left;font-size:10px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;border-bottom:1px solid var(--border)}
td{padding:8px 12px;border-bottom:1px solid var(--border);font-size:12px;vertical-align:middle}
tr:last-child td{border-bottom:none}
tr:hover td{background:var(--surface2)}
.mono{font-family:'IBM Plex Mono',monospace;font-weight:600}

/* ── Badges ── */
.badge{display:inline-block;padding:2px 7px;border-radius:4px;font-size:10px;font-weight:600}
.bg{background:#1A3A1F;color:var(--green)}
.br{background:#3A1A1A;color:var(--red)}
.bb{background:#1A2A3A;color:var(--accent)}
.bm{background:#2A2A2A;color:var(--muted)}
.bo{background:#3A2A0A;color:var(--orange)}

/* ── Buttons ── */
.btn{padding:7px 14px;border-radius:6px;font-size:12px;font-weight:600;cursor:pointer;font-family:inherit;transition:all .15s;border:none}
.btn-primary{background:var(--accent);color:#fff}.btn-primary:hover{opacity:.85}
.btn-sec{background:var(--surface2);color:var(--text);border:1px solid var(--border)}.btn-sec:hover{border-color:var(--accent);color:var(--accent)}
.btn-danger{background:#3A1A1A;color:var(--red);border:1px solid #5A2A2A}.btn-danger:hover{background:#5A1A1A}
.btn-xs{padding:3px 8px;font-size:11px}

/* ── Forms ── */
.form-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:12px;margin-bottom:14px}
.form-group{display:flex;flex-direction:column;gap:4px}
.form-label{font-size:10px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}
.form-input,.form-select{padding:7px 10px;background:var(--bg);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:12px;font-family:inherit;transition:border-color .15s}
.form-input:focus,.form-select:focus{outline:none;border-color:var(--accent);background:var(--surface2)}

/* ── Nov table ── */
.nov-input{width:65px;padding:5px 7px;background:var(--bg);border:1px solid var(--border);border-radius:5px;color:var(--text);font-family:'IBM Plex Mono',monospace;font-size:12px;text-align:right}
.nov-input:focus{outline:none;border-color:var(--accent)}

/* ── Toast ── */
.toast{position:fixed;bottom:20px;right:20px;padding:10px 16px;border-radius:7px;font-size:12px;font-weight:600;z-index:9999;display:none;border:1px solid;transition:opacity .2s}
.toast-ok{background:#0D2818;border-color:#1A5C2E;color:var(--green)}
.toast-err{background:#2D0E0E;border-color:#5C1A1A;color:var(--red)}

/* ── States ── */
.empty{text-align:center;padding:40px;color:var(--muted)}
.empty .icon{font-size:32px;margin-bottom:10px}

.preview-promotion-panel {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
    color: var(--text);
    font-size: 12px;
    line-height: 1.6;
}
.preview-promotion-title {
    font-weight: 700;
    color: var(--accent);
    font-size: 13px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.preview-promotion-warning {
    color: var(--orange);
    font-size: 11px;
    margin-bottom: 10px;
    font-weight: 500;
}
.preview-promotion-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.preview-promotion-badge {
    background: var(--surface);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--muted);
    margin-right: 4px;
}

/* ── Parity Panel Styles ── */
.preview-parity-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
    color: var(--text);
    font-size: 12px;
    line-height: 1.6;
}
.preview-parity-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.preview-parity-warning {
    color: var(--red);
    font-size: 11px;
    margin-bottom: 10px;
    font-weight: 500;
}
.preview-parity-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}
.preview-parity-badge {
    background: var(--surface2);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-size: 11px;
}
.preview-parity-table {
    width: 100%;
    font-size: 11px;
    margin-top: 10px;
    border-collapse: collapse;
}
.preview-parity-table th {
    padding: 6px;
    text-align: left;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.preview-parity-table td {
    padding: 6px;
    border-bottom: 1px dashed var(--border);
}
.preview-parity-badge-state {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

/* ── Ayuda Contextual ── */
.help-floating-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
  transition: transform .15s, opacity .15s;
}
.help-floating-btn:hover {
  transform: scale(1.05);
  opacity: 0.95;
}
.help-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.help-modal-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 560px;
  max-width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.help-modal-container-loading {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 560px;
  max-width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.help-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  font-weight: 600;
}
.help-modal-close:hover {
  color: var(--text);
}
.liquidation-error-overlay { z-index: 10000; }
.liquidation-error-dialog { width: 640px; border-color: var(--red); box-shadow: 0 24px 70px rgba(0,0,0,.55); }
.liquidation-error-dialog__title { margin: 0 0 16px; padding-right: 24px; color: var(--red); font-size: 20px; line-height: 1.3; }
.liquidation-error-dialog__message { margin: 0; color: var(--text); font-size: 14px; line-height: 1.65; white-space: pre-wrap; user-select: text; }
.liquidation-error-dialog__button { display: block; min-width: 130px; margin: 24px 0 0 auto; }
.help-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}
.help-section {
  margin-bottom: 14px;
}
.help-section-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--accent);
}
.help-text {
  color: var(--text);
  line-height: 1.5;
}
.help-list {
  color: var(--text);
  line-height: 1.5;
  padding-left: 20px;
  margin-top: 4px;
}
.help-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}
.help-footer {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}
.help-error-container {
  text-align: center;
  padding: 10px;
}
.help-error-icon {
  font-size: 32px;
  margin-bottom: 12px;
}
.help-error-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--red);
  margin-bottom: 8px;
}
.help-error-msg {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.help-error-detail {
  font-size: 10px;
  color: var(--muted);
  font-family: monospace;
}

/* ── Modales y Ajuste Manual (PEND-009) ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.modal-hdr strong {
  font-size: 14px;
  font-weight: 600;
}
.modal-body {
  padding: 16px;
  overflow-y: auto;
  font-size: 13px;
}
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

/* ── Pantalla Usuarios del Sistema (Runtime-265D.UI1) ── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-usuarios {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.table-usuarios th {
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.table-usuarios td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  vertical-align: middle;
}

.table-usuarios tr:hover td {
  background: var(--surface2);
}

.user-username-cell {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.user-name-cell {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.user-empresa-cell {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.user-contact-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
}

.user-email {
  font-weight: 500;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
}

.user-phone {
  font-size: 11px;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
}

.user-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.table-usuarios th:last-child, .table-usuarios td:last-child { width: 120px; min-width: 120px; }
.user-more-actions { min-width: 30px; font-size: 18px; line-height: 1; padding: 2px 8px; }
.user-actions-menu { position: fixed; z-index: 10020; display: flex; flex-direction: column; min-width: 210px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 35px rgba(0,0,0,.45); }
.user-actions-menu__item { width: 100%; padding: 9px 10px; border: 0; border-radius: 5px; background: transparent; color: var(--text); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.user-actions-menu__item:hover, .user-actions-menu__item:focus { background: var(--surface2); outline: none; }
.user-actions-menu__item--danger { color: var(--red); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}

.btn-temp-pass {
  opacity: 0.65;
  font-size: 10px;
}

.btn-temp-pass:hover {
  opacity: 1;
  color: var(--orange);
  border-color: var(--orange);
  background: rgba(210, 153, 34, 0.1);
}

/* Badges compatibility aliases */
.badge-ok { background: #1A3A1F; color: var(--green); }
.badge-warn { background: #3A2A0A; color: var(--orange); }
.badge-danger { background: #3A1A1A; color: var(--red); }
.badge-muted { background: #2A2A2A; color: var(--muted); }

/* Responsive strategy: tabla completa con scroll en tablet/mobile + ocultamiento progresivo */
@media (max-width: 768px) {
  .col-hide-mobile {
    display: none !important;
  }
  .user-email {
    max-width: 140px;
  }
  .user-name-cell {
    max-width: 120px;
  }
}



