/* ══ BASE CSS ════════════════════════════════════════════ v2.3 ══ */
/* ══ DESIGN TOKENS ══════════════════════════════════════════════ */
:root {
  --bg:       #0c0c0c;
  --s1:       #111111;
  --s2:       #181818;
  --s3:       #1f1f1f;
  --s4:       #282828;
  --b1:       #222222;
  --b2:       #2e2e2e;
  --b3:       #3a3a3a;
  --tx:       #e2e2e2;
  --tx2:      #888888;
  --tx3:      #555555;
  --acc:      #c8f135;   /* lima */
  --acc2:     #35c8f1;   /* cyan */
  --warn:     #f1c435;
  --danger:   #f15535;
  --ok:       #35f189;
  --purple:   #a78bfa;
  --mono:     'IBM Plex Mono', monospace;
  --sans:     'IBM Plex Sans', sans-serif;
  --r:        4px;
  --r2:       8px;
  --shadow:   0 4px 24px rgba(0,0,0,.5);
}

/* ══ RESET ══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--tx);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  display: flex;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--b3); border-radius: 2px; }

/* ══ USER SELECTOR ══════════════════════════════════════════════ */
.us-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

.us-box {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px;
}

.us-logo {
  width: 48px; height: 48px;
  background: var(--acc);
  border-radius: var(--r2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 15px; font-weight: 700;
  color: #0c0c0c;
  margin-bottom: 8px;
}

.us-title {
  font-family: var(--mono);
  font-size: 13px; font-weight: 600;
  letter-spacing: .2em;
  color: var(--tx2);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.us-sub {
  font-size: 12px; color: var(--tx3);
  font-family: var(--mono);
  margin-bottom: 24px;
}

.us-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 400px;
}

.us-btn {
  height: 56px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: var(--r2);
  color: var(--tx);
  font-family: var(--mono);
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
}
.us-btn:hover {
  border-color: var(--acc);
  background: rgba(200,241,53,.06);
  color: var(--acc);
}
.us-btn .us-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--b3);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
}

/* ══ APP SHELL ══════════════════════════════════════════════════ */
.app-shell { display: flex; width: 100%; height: 100vh; overflow: hidden; }

/* ══ SIDEBAR ════════════════════════════════════════════════════ */
.sidebar {
  width: 52px;
  background: var(--s1);
  border-right: 1px solid var(--b1);
  display: flex; flex-direction: column;
  align-items: center;
  padding: 8px 0 14px;
  gap: 2px;
  flex-shrink: 0;
  overflow: hidden;
  transition: width .2s cubic-bezier(.4,0,.2,1);
  z-index: 10;
}
.sidebar.expanded { width: 192px; }

/* Toggle button */
.sb-toggle {
  width: 100%; height: 28px;
  background: transparent;
  border: none;
  color: var(--tx3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  transition: color .12s, background .12s;
  flex-shrink: 0;
  margin-bottom: 4px;
}
.sb-toggle:hover { color: var(--tx); background: var(--s2); }
#sb-toggle-ic {
  display: inline-block;
  transition: transform .2s cubic-bezier(.4,0,.2,1);
}
.sidebar.expanded #sb-toggle-ic { transform: rotate(180deg); }

.sb-logo {
  width: 30px; height: 30px;
  background: var(--acc);
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  color: #0c0c0c;
  margin-bottom: 14px; flex-shrink: 0;
}

.sb-nav { display: flex; flex-direction: column; gap: 2px; width: 100%; flex: 1; }
.sb-bottom { width: 100%; padding: 0 0 4px; }
.sb-divider { height: 1px; background: var(--b1); margin: 8px 11px; }

.ni {
  width: 100%;
  height: 36px;
  display: flex; align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  color: var(--tx3);
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
  text-align: left;
}
.ni:hover { background: var(--s2); color: var(--tx); }
.ni.active {
  background: rgba(200,241,53,.07);
  border-left-color: var(--acc);
  color: var(--acc);
}
.ni-ic {
  font-size: 14px; flex-shrink: 0; width: 18px; text-align: center;
  display: flex; align-items: center; justify-content: center;
}
.ni-ic svg { display: block; }
.ni-lbl {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  opacity: 0; transition: opacity .15s;
  pointer-events: none; white-space: nowrap;
}
.sidebar.expanded .ni-lbl { opacity: 1; }

.sb-user {
  margin: 4px 8px 0;
  padding: 8px;
  border-radius: var(--r);
  cursor: pointer;
  display: flex; align-items: center; gap: 9px;
  min-height: 36px;
  transition: background .12s;
  overflow: hidden;
}
.sb-user:hover { background: var(--s2); }
.sb-user-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--b3);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  color: var(--tx2); flex-shrink: 0;
}
.sb-user-name {
  font-family: var(--mono); font-size: 11px; color: var(--tx2);
  opacity: 0; transition: opacity .15s; white-space: nowrap;
}
.sidebar.expanded .sb-user-name { opacity: 1; }

/* ══ MAIN AREA ══════════════════════════════════════════════════ */
.main-area {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}

.topbar {
  height: 48px; flex-shrink: 0;
  background: var(--s1);
  border-bottom: 1px solid var(--b1);
  display: flex; align-items: center;
  padding: 0 18px; gap: 10px;
}
.tb-left { display: flex; align-items: center; gap: 8px; flex: 1; }
.tb-mod {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--tx2); letter-spacing: .1em; text-transform: uppercase;
}
.tb-right { display: flex; align-items: center; gap: 6px; }

.sync-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); transition: background .3s;
}
.sync-dot.loading { background: var(--warn); animation: pulse .8s infinite; }
.sync-dot.error   { background: var(--danger); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

#module-container {
  flex: 1; overflow-x: auto; overflow-y: hidden;
  display: flex; flex-direction: column;
}

/* ══ TOASTS ═════════════════════════════════════════════════════ */
#toasts {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 7px;
  z-index: 9999; pointer-events: none;
}
.toast {
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r2);
  padding: 9px 14px;
  font-family: var(--mono); font-size: 11px;
  display: flex; align-items: center; gap: 8px;
  min-width: 220px; max-width: 340px;
  box-shadow: var(--shadow);
  animation: toast-in .18s ease;
  pointer-events: all;
}
.toast.ok     { border-color: rgba(53,241,137,.3); color: var(--ok); }
.toast.err    { border-color: rgba(241,85,53,.3);  color: var(--danger); }
.toast.warn   { border-color: rgba(241,196,53,.3); color: var(--warn); }
.toast.info   { border-color: rgba(53,200,241,.3); color: var(--acc2); }
@keyframes toast-in { from{opacity:0;transform:translateX(12px)} to{opacity:1;transform:none} }

/* ══ TOOLBAR PATTERN ════════════════════════════════════════════ */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--b1);
  background: var(--s1);
  flex-shrink: 0; flex-wrap: wrap;
}
.tb-grp { display: flex; align-items: center; gap: 5px; }
.tb-lbl { font-family: var(--mono); font-size: 9px; color: var(--tx3); white-space: nowrap; }
.tb-sep { width: 1px; height: 18px; background: var(--b2); margin: 0 2px; }
.ml-auto { margin-left: auto; }

/* ══ FORM CONTROLS ══════════════════════════════════════════════ */
.inp {
  height: 28px;
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r);
  color: var(--tx);
  font-family: var(--mono); font-size: 11px;
  padding: 0 8px;
  outline: none;
  transition: border-color .12s;
}
.inp:focus { border-color: var(--acc); }
.inp::placeholder { color: var(--tx3); }
.inp-lg { height: 32px; font-size: 12px; }

select.inp option { background: var(--s3); }

textarea.inp {
  height: auto; padding: 6px 8px;
  resize: vertical; line-height: 1.5;
}

.fg {
  display: flex; flex-direction: column; gap: 4px;
}
.fg label {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  color: var(--tx3); text-transform: uppercase; letter-spacing: .07em;
}
.fg .inp { width: 100%; }

.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }

/* ══ SECTIONS ═══════════════════════════════════════════════════ */
.sec {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r2);
  margin-bottom: 10px;
  overflow: hidden;
}
.sec-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}
.sec-hd:hover { background: var(--s3); }
.sec-title {
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  color: var(--tx3); text-transform: uppercase; letter-spacing: .12em;
  display: flex; align-items: center; gap: 7px;
}
.sec-tog { color: var(--tx3); font-size: 10px; transition: transform .15s; }
.sec.collapsed .sec-tog { transform: rotate(-90deg); }
.sec.collapsed .sec-body { display: none; }
.sec-body { padding: 12px 14px; border-top: 1px solid var(--b1); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ══ TABLES ═════════════════════════════════════════════════════ */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  padding: 7px 10px;
  text-align: left;
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  color: var(--tx3); text-transform: uppercase; letter-spacing: .07em;
  border-bottom: 1px solid var(--b2);
  white-space: nowrap;
  background: var(--s2);
  position: sticky; top: 0; z-index: 1;
}
.tbl thead th.r, .tbl td.r { text-align: right; }
.tbl td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--b1);
  font-size: 12px;
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { cursor: pointer; transition: background .08s; }
.tbl tbody tr:hover td { background: rgba(255,255,255,.02); }
.tbl tbody tr.sel td { background: rgba(200,241,53,.05) !important; }

/* ══ BADGES / PILLS ═════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  padding: 2px 7px; border-radius: 3px;
  border: 1px solid; text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.badge-ok      { color: var(--ok);     border-color: rgba(53,241,137,.3);  background: rgba(53,241,137,.07); }
.badge-warn    { color: var(--warn);   border-color: rgba(241,196,53,.3);  background: rgba(241,196,53,.07); }
.badge-danger  { color: var(--danger); border-color: rgba(241,85,53,.3);   background: rgba(241,85,53,.07); }
.badge-neutral { color: var(--tx3);   border-color: var(--b2);            background: var(--s3); }
.badge-info    { color: var(--acc2);  border-color: rgba(53,200,241,.3);  background: rgba(53,200,241,.07); }
.badge-acc     { color: var(--acc);   border-color: rgba(200,241,53,.3);  background: rgba(200,241,53,.07); }

/* ══ EMPTY STATE ════════════════════════════════════════════════ */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 60px 20px;
  color: var(--tx3); font-family: var(--mono); font-size: 11px;
}
.empty-icon { font-size: 30px; opacity: .15; }

/* ══ LOADING ════════════════════════════════════════════════════ */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--b3);
  border-top-color: var(--acc);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ OVERLAY / MODAL ════════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
.overlay.open { opacity: 1; pointer-events: all; }
.overlay.open .modal { transform: translateY(0); }

.modal {
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: var(--r2);
  width: 560px; max-width: 95vw;
  max-height: 88vh; overflow-y: auto;
  transform: translateY(10px);
  transition: transform .18s;
  display: flex; flex-direction: column;
}
.modal-lg { width: 720px; }
.modal-xl { width: 900px; }

.modal-hd {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--b1);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--s2); z-index: 1;
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--tx);
}
.modal-close {
  background: none; border: none; color: var(--tx3);
  font-size: 17px; cursor: pointer; padding: 0 2px;
  transition: color .12s; line-height: 1;
}
.modal-close:hover { color: var(--tx); }
.modal-body { padding: 18px; flex: 1; }
.modal-ft {
  padding: 12px 18px;
  border-top: 1px solid var(--b1);
  display: flex; justify-content: flex-end; gap: 7px;
  position: sticky; bottom: 0; background: var(--s2);
  flex-shrink: 0;
}

/* ══ DETAIL PANEL ═══════════════════════════════════════════════ */
.panel {
  width: 360px; flex-shrink: 0;
  border-left: 1px solid var(--b1);
  background: var(--s1);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width .15s cubic-bezier(.4,0,.2,1);
}
.panel.closed { width: 0; border: none; overflow: hidden; }
.panel-scroll { flex: 1; overflow-y: auto; }
.panel-ft {
  padding: 10px 12px;
  border-top: 1px solid var(--b1);
  display: flex; gap: 6px; flex-wrap: wrap;
  flex-shrink: 0;
}

.pd-hd {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--b1);
}
.pd-num  { font-family: var(--mono); font-size: 10px; color: var(--tx3); margin-bottom: 2px; }
.pd-name { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.pd-dates { font-family: var(--mono); font-size: 10px; color: var(--tx3); margin-bottom: 8px; }
.pd-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.pd-sec { border-bottom: 1px solid var(--b1); }
.pd-sec-hd {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 14px; cursor: pointer;
}
.pd-sec-hd:hover { background: var(--s2); }
.pd-sec-lbl { font-family: var(--mono); font-size: 9px; font-weight: 700; color: var(--tx3); text-transform: uppercase; letter-spacing: .07em; }
.pd-sec-tog { font-size: 10px; color: var(--tx3); transition: transform .12s; }
.pd-sec.coll .pd-sec-tog  { transform: rotate(-90deg); }
.pd-sec.coll .pd-sec-body { display: none; }
.pd-sec-body { padding: 4px 14px 12px; }

.pd-row {
  display: flex; justify-content: space-between;
  padding: 3px 0;
  font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.pd-row-l { color: var(--tx3); flex: 1; }
.pd-row-r { font-family: var(--mono); font-weight: 500; text-align: right; }
.pd-row-r.hi  { color: var(--acc);    font-size: 13px; font-weight: 700; }
.pd-row-r.warn { color: var(--warn); }
.pd-row-r.ok  { color: var(--ok); }

.pd-chip {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 9px;
  padding: 2px 6px; border-radius: 3px;
  background: var(--s3); border: 1px solid var(--b2);
  color: var(--tx2); margin: 2px 2px 2px 0;
}

/* ══ PAGO CARD ══════════════════════════════════════════════════ */
.pago-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px;
  background: var(--s3); border: 1px solid var(--b2);
  border-radius: var(--r); margin-bottom: 5px;
}
.pago-monto { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--ok); }
.pago-meta  { font-family: var(--mono); font-size: 10px; color: var(--tx3); margin-top: 2px; }

/* ══ SETTINGS TABS ══════════════════════════════════════════════ */
.set-tabs {
  display: flex; border-bottom: 1px solid var(--b1);
  overflow-x: auto; flex-shrink: 0;
}
.set-tab {
  padding: 10px 16px;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--tx3); cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all .12s; background: none; border-left: none; border-right: none; border-top: none;
}
.set-tab:hover { color: var(--tx); }
.set-tab.active { color: var(--acc); border-bottom-color: var(--acc); }
.set-panel { display: none; padding: 18px; overflow-y: auto; flex: 1; }
.set-panel.active { display: block; }
