/* ===== DESIGN SYSTEM ===== */
:root {
  --primary:        #0F172A;
  --primary-light:  #1E293B;
  --secondary:      #0EA5E9;
  --secondary-dark: #0284C7;
  --bg:             #F8FAFC;
  --surface:        #FFFFFF;
  --border:         #E2E8F0;
  --border-strong:  #CBD5E1;
  --text:           #1E293B;
  --text-muted:     #64748B;
  --text-light:     #94A3B8;

  --status-green:   #16A34A;
  --status-green-bg:#DCFCE7;
  --status-blue:    #2563EB;
  --status-blue-bg: #DBEAFE;
  --status-orange:  #EA580C;
  --status-orange-bg:#FFEDD5;
  --status-red:     #DC2626;
  --status-red-bg:  #FEE2E2;
  --status-gray:    #64748B;
  --status-gray-bg: #F1F5F9;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0/0.05);
  --shadow:    0 1px 3px 0 rgb(0 0 0/0.1), 0 1px 2px -1px rgb(0 0 0/0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0/0.1), 0 2px 4px -2px rgb(0 0 0/0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0/0.1), 0 4px 6px -4px rgb(0 0 0/0.1);

  --sidebar-w: 240px;
  --topbar-h:  60px;
  --font: 'Inter', 'Roboto', system-ui, sans-serif;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); min-height: 100vh; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.empty-state { text-align: center; color: var(--text-muted); padding: 40px 16px; font-style: italic; }

/* ===== LOGIN ===== */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--primary);
  padding: 16px;
}
.login-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 40px 32px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.logo-mark {
  width: 44px; height: 44px; background: var(--primary);
  color: #fff; font-size: 16px; font-weight: 700; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.login-brand { font-size: 18px; font-weight: 700; color: var(--text); }
.login-sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.login-form  { display: flex; flex-direction: column; gap: 16px; }
.form-group  { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
  color: var(--text); transition: border-color .15s;
  outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgb(14 165 233/0.15);
}
.login-error { color: var(--status-red); font-size: 13px; background: var(--status-red-bg); padding: 10px 12px; border-radius: var(--radius); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--secondary); color: #fff; }
.btn-primary:hover { background: var(--secondary-dark); }
.btn-outline { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
.btn-outline:hover { background: var(--bg); }
.btn-full { width: 100%; justify-content: center; }

/* ===== APP LAYOUT ===== */
.app { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w); background: var(--primary);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh; z-index: 200;
  transition: transform .25s ease;
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: var(--topbar-h);
  border-bottom: 1px solid rgb(255 255 255/0.08);
}
.sidebar-title { color: #fff; font-size: 15px; font-weight: 700; flex: 1; }
.sidebar-close { color: rgb(255 255 255/0.5); font-size: 16px; display: none; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  color: rgb(255 255 255/0.65); font-size: 14px; font-weight: 500;
  width: 100%; transition: all .15s; text-align: left;
}
.nav-item:hover { background: rgb(255 255 255/0.08); color: #fff; }
.nav-item.active { background: var(--secondary); color: #fff; }
.nav-icon { font-size: 16px; }
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid rgb(255 255 255/0.08);
  display: flex; align-items: center; gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px; background: var(--secondary);
  border-radius: var(--radius-full); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-name  { color: #fff; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role  { color: rgb(255 255 255/0.5); font-size: 11px; }
.btn-logout { color: rgb(255 255 255/0.5); font-size: 18px; padding: 4px; }
.btn-logout:hover { color: #fff; }

/* MAIN WRAPPER */
.main-wrapper {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-height: 100vh;
}

/* TOPBAR */
.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px; position: sticky; top: 0; z-index: 100;
}
.menu-toggle { font-size: 20px; color: var(--text-muted); display: none; }
.topbar-title { font-size: 18px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }

/* VIEWS */
.view { display: none; }
.view.active { display: block; }
.view-inner { padding: 24px; max-width: 1600px; }

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 28px;
}
.kpi-card {
  background: var(--surface); border-radius: var(--radius-md);
  padding: 20px; box-shadow: var(--shadow);
  border-left: 4px solid transparent; position: relative;
}
.kpi-blue   { border-left-color: var(--status-blue); }
.kpi-red    { border-left-color: var(--status-red); }
.kpi-green  { border-left-color: var(--status-green); }
.kpi-orange { border-left-color: var(--status-orange); }
.kpi-label  { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.kpi-value  { font-size: 36px; font-weight: 700; margin: 8px 0 4px; color: var(--text); }
.kpi-desc   { font-size: 12px; color: var(--text-muted); }

/* ===== SECTION HEADER ===== */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.section-header h2 { font-size: 18px; font-weight: 600; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: var(--radius-full);
  border: 1px solid var(--border); font-size: 12px; font-weight: 600;
  color: var(--text-muted); background: var(--surface); cursor: pointer; transition: all .15s;
}
.chip.active, .chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== TABLES ===== */
.table-wrapper { background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow); overflow: hidden; }
.table-scroll  { overflow-x: auto; }
.data-table thead th {
  padding: 12px 14px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; white-space: nowrap;
  text-align: left;
}
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #F1F5F9; cursor: pointer; }
.data-table tbody td { padding: 12px 14px; font-size: 14px; vertical-align: middle; }
.density-compact tbody td { padding: 8px 14px; }

/* Row states */
tr.row-urgente   { background: #FFF5F5 !important; }
tr.row-urgente.row-blink td:first-child { animation: blink-red 1.5s ease-in-out infinite; }
tr.row-entregado { background: #F0FDF4 !important; }
tr.row-observacion { background: #FFFBEB !important; }

@keyframes blink-red {
  0%, 100% { box-shadow: inset 3px 0 0 var(--status-red); }
  50%       { box-shadow: inset 3px 0 0 transparent; }
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; white-space: nowrap;
}
.badge-green  { background: var(--status-green-bg);  color: var(--status-green); }
.badge-blue   { background: var(--status-blue-bg);   color: var(--status-blue); }
.badge-orange { background: var(--status-orange-bg); color: var(--status-orange); }
.badge-red    { background: var(--status-red-bg);    color: var(--status-red); }
.badge-gray   { background: var(--status-gray-bg);   color: var(--status-gray); }

/* ===== STATUS DROPDOWNS ===== */
.status-select {
  appearance: none; border: none; font-family: var(--font);
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
  padding: 3px 8px; border-radius: var(--radius-full); cursor: pointer;
  background-image: none; outline: none; transition: opacity .15s;
}
.status-select:hover { opacity: 0.8; }
.status-terminado  { background: var(--status-green-bg);  color: var(--status-green); }
.status-proceso    { background: var(--status-blue-bg);   color: var(--status-blue); }
.status-observacion { background: var(--status-orange-bg); color: var(--status-orange); }
.status-urgente    { background: var(--status-red-bg);    color: var(--status-red); }
.status-espera     { background: var(--status-gray-bg);   color: var(--status-gray); }
.status-entregado  { background: var(--status-green-bg);  color: var(--status-green); }
.status-no-entregado { background: var(--status-red-bg);  color: var(--status-red); }
.status-listo      { background: var(--status-orange-bg); color: var(--status-orange); }

/* ===== TOOLBAR ===== */
.toolbar { margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0 12px;
}
.search-box input { flex: 1; border: none; padding: 10px 0; outline: none; background: transparent; }
.search-icon { color: var(--text-muted); }
.filters-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-select {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
  color: var(--text); font-size: 13px; outline: none;
  cursor: pointer; min-width: 120px;
}
.filter-select--lg { min-width: 220px; font-size: 14px; padding: 9px 12px; }
.filter-select:focus { border-color: var(--secondary); }

/* ===== PAGINATION ===== */
.pagination { display: flex; justify-content: flex-end; gap: 6px; padding: 16px 0; }
.page-btn {
  padding: 6px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); font-size: 13px;
  background: var(--surface); color: var(--text);
  cursor: pointer; transition: all .15s;
}
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:hover:not(.active) { background: var(--bg); }

/* ===== LINKS ===== */
.icon-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--border); color: var(--text-muted);
  transition: all .15s; white-space: nowrap;
}
.icon-link:hover { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.icon-link-wrap { display: flex; gap: 4px; }

/* ===== BITÁCORA BUTTON ===== */
.bitacora-btn {
  padding: 4px 10px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-muted);
  cursor: pointer; transition: all .15s;
}
.bitacora-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== DRAWER ===== */
.drawer-overlay {
  position: fixed; inset: 0; background: rgb(0 0 0/0.3);
  z-index: 300; backdrop-filter: blur(2px);
}
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 400px;
  background: var(--surface); box-shadow: var(--shadow-lg);
  z-index: 400; display: flex; flex-direction: column;
  transform: translateX(0); transition: transform .25s ease;
}
.drawer.hidden { transform: translateX(100%); display: flex !important; visibility: hidden; }
.drawer-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border);
}
.drawer-header h2 { font-size: 16px; font-weight: 600; }
.drawer-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-family: monospace; }
.drawer-close { font-size: 18px; color: var(--text-muted); padding: 2px; }
.drawer-close:hover { color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.drawer-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.note-textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); resize: vertical; outline: none; }
.note-textarea:focus { border-color: var(--secondary); }

/* BITÁCORA FEED */
.bitacora-feed { display: flex; flex-direction: column; gap: 12px; }
.bitacora-entry {
  padding: 10px 12px; background: var(--bg);
  border-radius: var(--radius); border-left: 3px solid var(--secondary);
}
.bitacora-meta { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.bitacora-text { font-size: 13px; line-height: 1.5; }

/* ===== HISTORIAL ===== */
.historico-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 16px;
}
.historico-header h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.alert-warning {
  background: #FFFBEB; border: 1px solid #FCD34D; border-radius: var(--radius);
  padding: 12px 16px; font-size: 13px; font-weight: 700; color: #92400E;
  letter-spacing: 0.01em; margin-bottom: 16px;
}
.historico-empty {
  text-align: center; padding: 80px 20px;
  color: var(--text-muted); font-size: 16px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgb(0 0 0/0.4);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  padding: 16px; backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 640px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface);
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close { font-size: 20px; color: var(--text-muted); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-group--full { grid-column: 1 / -1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== CONFIG PANEL ===== */
.config-header { margin-bottom: 20px; }
.config-header h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }

.config-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  overflow-x: auto; padding-bottom: 2px;
}
.config-tab {
  padding: 8px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); font-size: 14px; font-weight: 600;
  color: var(--text-muted); background: var(--surface); white-space: nowrap;
  transition: all .15s; cursor: pointer;
}
.config-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.config-tab:hover:not(.active) { background: var(--bg); color: var(--text); }

.tab-panel { display: block; }

.config-card {
  background: var(--surface); border-radius: var(--radius-md);
  padding: 24px; box-shadow: var(--shadow);
}
.config-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.config-section-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.config-divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.config-add-row { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; }
.config-input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-family: var(--font); font-size: 14px; outline: none;
  background: var(--bg);
}
.config-input:focus { border-color: var(--secondary); background: var(--surface); }

.config-list {
  list-style: none; display: flex; flex-direction: column; gap: 6px;
  max-height: 400px; overflow-y: auto;
}
.config-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--bg); border-radius: var(--radius);
  border: 1px solid var(--border); font-size: 14px;
}
.config-list-item span { font-weight: 500; }
.config-list-item .encargado-meta { font-size: 12px; color: var(--text-muted); }
.config-delete-btn {
  padding: 4px 10px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--status-red-bg);
  background: var(--status-red-bg); color: var(--status-red);
  cursor: pointer; transition: all .15s; flex-shrink: 0;
}
.config-delete-btn:hover { background: var(--status-red); color: #fff; border-color: var(--status-red); }

.form-grid--3 { grid-template-columns: repeat(3, 1fr); }

/* ===== MODAL SIZES ===== */
.modal--lg { max-width: 780px; }

/* ===== MODAL BLOCK TITLES ===== */
.modal-block-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  margin: 20px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0;
}

/* ===== CODE PREVIEW ===== */
.code-preview-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 4px;
  border: 1px dashed var(--border-strong);
}
.code-preview-label { font-size: 12px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.code-preview-value {
  font-family: 'Courier New', monospace; font-size: 15px; font-weight: 700;
  color: var(--secondary); letter-spacing: 0.05em;
}

/* ===== CLIENTE FORM ENTRY ===== */
.cliente-entry {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 10px;
}
.cliente-entry-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.cliente-entry-header span { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.remove-client-btn {
  padding: 2px 8px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer;
}
.remove-client-btn:hover { background: var(--status-red-bg); color: var(--status-red); border-color: var(--status-red-bg); }
.form-grid--cliente { grid-template-columns: 2fr 1.5fr 1.5fr 1fr 1fr; }

/* ===== ACTIVIDAD COLUMN ===== */
.act-cell { max-width: 160px; }
.act-text {
  font-size: 12px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 140px;
  display: block;
}
.act-edit-btn {
  font-size: 11px; color: var(--secondary); cursor: pointer;
  background: none; border: none; padding: 2px 4px; opacity: 0.7;
}
.act-edit-btn:hover { opacity: 1; }

/* ===== INFO SOLICITADA / DRAWER ===== */
.entry-enviado {
  border-left-color: var(--status-green) !important;
  background: var(--status-green-bg) !important;
}
.entry-enviado .bitacora-meta { color: var(--status-green); }
.btn-enviado {
  padding: 8px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 700;
  background: var(--status-green-bg); color: var(--status-green);
  border: 1px solid var(--status-green); cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-enviado:hover { background: var(--status-green); color: #fff; }

/* ===== CONFIG SIGLAS INPUT ===== */
.config-input--sm { max-width: 90px; font-weight: 700; text-transform: uppercase; }

/* ===== FILTER INPUT ===== */
.filter-input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: var(--font); outline: none; background: var(--surface);
  color: var(--text); max-width: 100px;
}
.filter-input:focus { border-color: var(--secondary); }

/* ===== PAGOS ===== */
.cuotas-cell { min-width: 180px; }
.cuotas-stack { display: flex; flex-wrap: wrap; gap: 4px; }
.cuota-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.cuota-badge select {
  appearance: none; border: none; font-family: var(--font);
  font-size: 11px; font-weight: 700; padding: 2px 6px;
  border-radius: var(--radius-full); cursor: pointer; outline: none;
}
.cuota-pagado select  { background: var(--status-green-bg); color: var(--status-green); }
.cuota-espera select  { background: var(--status-gray-bg);  color: var(--status-gray); }

/* ===== CUOTAS SECTION IN MODAL ===== */
.cuotas-grid { display: flex; flex-direction: column; gap: 8px; }
.cuota-row {
  display: grid; grid-template-columns: 80px 1fr 1fr 1fr 1fr auto;
  gap: 8px; align-items: center; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
}
.cuota-row .cuota-num { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.cuota-row .form-group { margin: 0; }
.cuota-row .form-group label { font-size: 11px; margin-bottom: 2px; }
.cuota-row .form-group input { padding: 5px 8px; font-size: 13px; }
.cuota-total-check { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.cuota-total-ok    { color: var(--status-green); font-weight: 700; }
.cuota-total-err   { color: var(--status-red);   font-weight: 700; }

/* ===== BTN SM ===== */
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== NOTIFICATION BADGES (actividad / info) ===== */
.excl-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  font-size: 10px; font-weight: 900; line-height: 1;
  background: var(--status-red); color: #fff;
  vertical-align: middle; margin-right: 3px; flex-shrink: 0;
}
.act-has-activity { color: var(--status-orange) !important; opacity: 1 !important; }
.bitacora-pending {
  background: var(--status-red-bg) !important;
  border-color: var(--status-red) !important;
  color: var(--status-red) !important;
}
.bitacora-sent {
  background: var(--status-green-bg) !important;
  border-color: var(--status-green) !important;
  color: var(--status-green) !important;
}
.reunion-pending {
  background: var(--status-orange-bg) !important;
  border-color: var(--status-orange) !important;
  color: var(--status-orange) !important;
}
.reunion-done {
  background: var(--status-green-bg) !important;
  border-color: var(--status-green) !important;
  color: var(--status-green) !important;
}
.reunion-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  font-size: 10px; font-weight: 900; line-height: 1;
  background: var(--status-green); color: #fff;
  vertical-align: middle; margin-right: 3px; flex-shrink: 0;
}
.status-encargado { background: var(--status-blue-bg); color: var(--status-blue); }

/* ===== DASHBOARD CHARTS ===== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.charts-grid-wide {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px 20px;
  box-shadow: var(--shadow);
}
.chart-card-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 14px;
}
.chart-wrap { position: relative; height: 200px; }
.chart-wrap-tall { position: relative; height: 240px; }

@media (max-width: 900px) {
  .charts-grid, .charts-grid-wide { grid-template-columns: 1fr; }
}

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--primary); color: #fff;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg);
  z-index: 1000; transition: opacity .3s; min-width: 200px;
  display: flex; align-items: center; gap: 8px;
}
.toast.toast-success { background: var(--status-green); }
.toast.toast-error   { background: var(--status-red); }

/* ===== CALENDAR ===== */
.cal-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow);
}
.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.cal-nav-title { font-size: 16px; font-weight: 700; }
.cal-nav-btn {
  padding: 6px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); font-size: 16px; cursor: pointer; transition: all .15s;
}
.cal-nav-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day-hdr {
  padding: 8px 4px; text-align: center; font-size: 11px; font-weight: 700;
  text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.cal-day {
  min-height: 78px; padding: 5px 5px 4px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  position: relative;
}
.cal-day--empty { background: var(--bg); }
.cal-day--today { background: #EFF6FF; }
.cal-day-num {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; margin-bottom: 3px;
}
.cal-day--today .cal-day-num { background: var(--secondary); color: #fff; }
.cal-events { display: flex; flex-direction: column; gap: 2px; }
.cal-event {
  font-size: 10px; font-weight: 600; padding: 2px 5px; border-radius: 3px;
  background: var(--status-blue-bg); color: var(--status-blue);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.cal-event:hover { background: var(--secondary); color: #fff; }
.cal-add-btn {
  font-size: 14px; width: 20px; height: 20px; border-radius: 50%;
  background: transparent; color: var(--text-light); border: 1px dashed var(--border);
  display: none; align-items: center; justify-content: center; cursor: pointer;
  position: absolute; top: 4px; right: 4px; line-height: 1;
}
.cal-day:hover .cal-add-btn { display: flex; }
.cal-add-btn:hover { background: var(--secondary); color: #fff; border-color: var(--secondary); }

/* ===== CHECKS GRID (participantes) ===== */
.checks-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 6px; max-height: 220px; overflow-y: auto; padding: 2px;
}
.check-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font-size: 13px; transition: background .1s;
}
.check-item:hover { background: var(--bg); }
.check-item input[type="checkbox"] { cursor: pointer; accent-color: var(--secondary); flex-shrink: 0; }
.check-item-name { flex: 1; font-weight: 500; }

/* ===== UPCOMING REUNIONES ===== */
.reunion-list { display: flex; flex-direction: column; gap: 10px; }
.reunion-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--secondary); border-radius: var(--radius);
  padding: 12px 16px; display: flex; align-items: center; gap: 12px;
}
.reunion-card-date { text-align: center; min-width: 44px; }
.reunion-card-day { font-size: 22px; font-weight: 700; line-height: 1; color: var(--secondary); }
.reunion-card-mon { font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.reunion-card-info { flex: 1; }
.reunion-card-title { font-weight: 600; font-size: 14px; }
.reunion-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .main-wrapper { margin-left: 0; }
  .menu-toggle { display: block; }
  .drawer { width: 100%; max-width: 420px; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 28px; }
  .view-inner { padding: 16px; }
  .topbar { padding: 0 16px; }
  .topbar-title { font-size: 15px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid--3 { grid-template-columns: 1fr; }
  .form-group--full { grid-column: 1; }
  .filters-row { gap: 6px; }
  .filter-select { min-width: 0; flex: 1; }
  .historico-header { flex-direction: column; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .modal { max-height: 100vh; border-radius: 0; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .config-add-row { flex-direction: column; }
  .config-input { width: 100%; }
  .config-input--sm { max-width: 100%; }
  .form-grid--cliente { grid-template-columns: 1fr 1fr; }
  .cuota-row { grid-template-columns: 1fr 1fr; gap: 6px; }
}

@media (max-width: 480px) {
  .kpi-card { padding: 14px; }
  .kpi-label { font-size: 11px; }
}

/* ══ ROLES Y PERMISOS ════════════════════════════════════════════════ */
.roles-perms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.rol-perms-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rol-perms-header {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}
.perm-panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin: 10px 0 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.perm-check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background .15s;
}
.perm-check-row:hover { background: var(--surface); }
.perm-check-row input[type="checkbox"] { accent-color: var(--secondary); width: 14px; height: 14px; flex-shrink: 0; cursor: pointer; }
.perm-check-row--locked { opacity: .65; cursor: default; }
.perm-check-row--locked input { cursor: not-allowed; }

/* ══ INTEGRANTE ENTRADA VERTICAL ═══════════════════════════════════ */
#nc-integrantes-list .cliente-entry {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#nc-integrantes-list .form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#nc-integrantes-list .form-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
#nc-integrantes-list .form-group input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  transition: border-color .2s;
}
#nc-integrantes-list .form-group input:focus {
  outline: none;
  border-color: var(--secondary);
}
.cliente-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

/* ══ CLIENTE SEARCH / TAGS ══════════════════════════════════════════ */
.cliente-search-item {
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border);
  font-size: 13px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); transition: background .15s;
}
.cliente-search-item:hover { background: var(--bg); }
.cliente-search-item:last-child { border-bottom: none; }
.cliente-search-noresult { padding: 8px 12px; color: var(--text-muted); font-size: 12px; }
#modal-cliente-results {
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
  background: var(--surface); max-height: 160px; overflow-y: auto;
}
.cliente-tag {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--status-blue-bg); color: var(--status-blue);
  border: 1px solid var(--status-blue); border-radius: 6px;
  padding: 6px 10px; font-size: 12px;
}
.cliente-tag button {
  background: transparent; border: none; color: var(--status-blue); cursor: pointer; font-size: 13px; padding: 0 4px;
}
.cliente-tag button:hover { color: var(--status-red); }

/* ══ RECURSOS GRID ══════════════════════════════════════════════════ */
.recursos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.recurso-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: box-shadow .2s, transform .2s;
}
.recurso-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-2px); }
.recurso-card-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.recurso-icon { font-size: 1.4rem; }
.recurso-link {
  font-size: 13px; font-weight: 600; color: var(--secondary);
  text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
}
.recurso-link:hover { text-decoration: underline; }
.recurso-notas { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.recurso-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }

/* ══ OBSERVACIÓN DRAWER ══════════════════════════════════════════════ */
/* reutiliza estilos del drawer existente — sin CSS extra necesario */

/* ══ DASHBOARD CHIPS nuevos procesos ════════════════════════════════ */
.badge-urgente { background: var(--status-red-bg); color: var(--status-red); }
.status-urgente { background: var(--status-red-bg); color: var(--status-red); border-color: var(--status-red); }
.status-medio-urgente { background: var(--status-orange-bg); color: var(--status-orange); border-color: var(--status-orange); }
.status-campo { background: var(--status-blue-bg); color: var(--status-blue); border-color: var(--status-blue); }
.status-revision { background: var(--status-blue-bg); color: var(--status-blue); border-color: var(--status-blue); }
.status-listo-entregar { background: var(--status-green-bg); color: var(--status-green); border-color: var(--status-green); }
.status-cotizacion { background: var(--status-gray-bg); color: var(--status-gray); border-color: var(--status-gray); }

/* ══ CONTABLE: TABS ════════════════════════════════════════════════ */
.contable-tabs { display:flex; gap:6px; margin-bottom:16px; border-bottom:2px solid var(--border); padding-bottom:0; }

/* ══ CALENDARIO DE PAGOS ═══════════════════════════════════════════ */
.pagos-cal-header {
  display:flex; align-items:center; justify-content:center; gap:20px; margin-bottom:14px;
}
.pagos-cal-legend {
  display:flex; gap:16px; margin-bottom:12px; font-size:12px; font-weight:600;
}
.cal-leg { display:flex; align-items:center; gap:5px; }
.cal-leg--pending { color:#b45309; }
.cal-leg--paid    { color:#065f46; }

.pagos-cal-grid {
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:5px;
}
.cal-dow {
  text-align:center; font-size:11px; font-weight:700;
  text-transform:uppercase; color:var(--text-muted); padding:6px 0;
}
.cal-day {
  min-height:78px; background:var(--surface);
  border:1.5px solid var(--border); border-radius:7px;
  padding:5px; overflow:hidden;
  transition:border-color .15s;
}
.cal-day--empty    { background:transparent; border-color:transparent; }
.cal-day--today    { border-color:var(--primary); background:#eef4ff; }
.cal-day--pending  { border-color:#f59e0b; }
.cal-day--all-paid { border-color:#10b981; }

.cal-day-num {
  font-size:11px; font-weight:700; color:var(--text-muted); margin-bottom:4px; line-height:1;
}
.cal-day--today .cal-day-num { color:var(--primary); }

.cal-events { display:flex; flex-direction:column; gap:3px; }

.cal-ev {
  border-radius:4px; padding:3px 5px; cursor:pointer;
  display:flex; flex-direction:column; gap:1px;
  font-size:10px; line-height:1.3; transition:opacity .15s;
  border-left:3px solid transparent;
}
.cal-ev:hover { opacity:.75; }
.cal-ev--pending { background:#fef3c7; color:#92400e; border-left-color:#f59e0b; }
.cal-ev--paid    { background:#d1fae5; color:#065f46; border-left-color:#10b981; }
.cal-ev-code  { font-weight:700; }
.cal-ev-cuota { opacity:.85; font-size:9px; }

/* ══ DOWNLOAD MENU ═════════════════════════════════════════════════ */
.dl-menu-wrap { position:relative; display:inline-block; }
.dl-menu {
  position:absolute; top:calc(100% + 4px); right:0; z-index:200;
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  box-shadow:0 4px 16px rgba(0,0,0,.12); min-width:160px; overflow:hidden;
}
.dl-menu button {
  display:block; width:100%; padding:10px 16px; text-align:left;
  font-size:13px; background:none; border:none; cursor:pointer; color:var(--text);
  transition:background .15s;
}
.dl-menu button:hover { background:var(--bg); }
