/* css/app.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Inter+Tight:wght@600;700&display=swap');

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

:root {
  --dya-blue:      #2196D3;
  --dya-blue-dark: #1670A8;
  --dya-blue-dim:  #0d4f7a;
  --dya-gray:      #1a1a1a;
  --dya-gray-2:    #252525;
  --dya-gray-3:    #333333;

  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --border:    #e4e8ef;
  --border-md: #cdd3de;

  --text:   #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;

  --accent:      var(--dya-blue);
  --accent-dark: var(--dya-blue-dark);
  --accent-bg:   #e8f4fc;
  --accent-text: #0d4f7a;

  --success:    #15803d;
  --success-bg: #dcfce7;
  --warn:       #92400e;
  --warn-bg:    #fef3c7;
  --danger:     #b91c1c;
  --danger-bg:  #fee2e2;

  --nav-w:    240px;
  --radius:   8px;
  --radius-lg:12px;

  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* ── Fix scroll jump al navegar entre páginas ───────────────── */
html { scroll-behavior: auto; }
body { min-height: 100vh; display: flex; }

/* ── Sidebar ────────────────────────────────────────────────── */
#sidebar {
  width: var(--nav-w);
  height: 100vh;
  background: var(--dya-gray);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
}

#sidebar .logo {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--dya-gray-3);
  margin-bottom: 6px;
  background: #111;
  flex-shrink: 0;
}
#sidebar .logo { min-height: 74px; }
#sidebar .logo img {
  width: 126px;
  display: block;
  height: 42px;
  object-fit: contain;
  object-position: left;
  mix-blend-mode: lighten;
}
#sidebar .logo-sub {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  /* Color legible sobre fondo oscuro */
  color: #5a7a8a;
  margin-top: 6px;
}

#sidebar nav { flex: 1; overflow-y: auto; }

#sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 400;
  color: #7a8a99;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s;
}
#sidebar nav a:hover { background: var(--dya-gray-2); color: #c9d3db; }
#sidebar nav a.active {
  background: rgba(33,150,211,.13);
  color: #5bbce8;
  border-left-color: var(--dya-blue);
  font-weight: 500;
}

/* Íconos SVG inline del sidebar */
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}
.nav-icon svg { display: block; }
#sidebar nav a       .nav-icon { color: #7a8a99; }
#sidebar nav a:hover .nav-icon { color: #c9d3db; }
#sidebar nav a.active .nav-icon { color: #5bbce8; }

/* Etiqueta "MENÚ" — color legible */
#sidebar .nav-section {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  /* Suficientemente visible sobre fondo oscuro */
  color: #5a7080;
  padding: 14px 16px 4px;
  flex-shrink: 0;
}

/* Footer sidebar — colores legibles */
#sidebar .sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--dya-gray-3);
  font-size: 10.5px;
  /* Color visible pero sutil */
  color: #6a8090;
  text-align: center;
  line-height: 1.7;
  flex-shrink: 0;
}
#sidebar .sidebar-footer a {
  color: #4a9aba;
  text-decoration: none;
}
#sidebar .sidebar-footer a:hover { color: var(--dya-blue); }

/* ── Main — scrollable sin saltos ───────────────────────────── */
#main {
  margin-left: var(--nav-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
#topbar h1 { font-size: 15px; font-weight: 700; font-family: 'Inter Tight', sans-serif; }
#topbar .topbar-right { display: flex; align-items: center; gap: 10px; }

#content { padding: 24px 28px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}
.card-title { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 5px; }
.card-value { font-size: 28px; font-weight: 700; color: var(--text); font-family: 'Inter Tight', sans-serif; line-height: 1.1; }
.card-sub   { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.card-grid  { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; margin-bottom: 22px; }
.card-accent-blue  { border-left: 3px solid var(--dya-blue); }
.card-accent-green { border-left: 3px solid var(--success); }
.card-accent-red   { border-left: 3px solid var(--danger); }
.card-accent-warn  { border-left: 3px solid #f59e0b; }

/* ── Tablas ─────────────────────────────────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: #f9fafb;
  white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* Acciones de tablas: aire real a la derecha para editar/eliminar */
td.td-actions,
th.th-actions {
  width: 128px;
  min-width: 128px;
  padding-right: 48px !important;
  text-align: right;
  white-space: nowrap;
}
.td-actions .action-buttons {
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}
.mov-note {
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-2);
  font-weight: 400;
}
.mov-note strong { color: var(--text-3); font-weight: 700; }

/* Bloqueo de cualquier fade anterior del main */
#main { opacity: 1 !important; transition: none !important; animation: none !important; }


/* Más aire al borde derecho en tablas de movimientos */
#tablaMovs td.td-actions,
#ultimosMovsBody td.td-actions {
  width: 136px;
  min-width: 136px;
  padding-right: 52px !important;
}
#tablaMovs .action-buttons,
#ultimosMovsBody .action-buttons {
  margin-right: 4px;
}
tfoot td { padding: 10px 14px; background: #f9fafb; border-top: 1px solid var(--border); font-size: 13px; }

/* ── Botones ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; font-size: 13px; font-weight: 500;
  border-radius: var(--radius); cursor: pointer; transition: all .13s;
  text-decoration: none; white-space: nowrap; font-family: inherit; line-height: 1;
}
.btn-primary { background: var(--dya-blue); color: #fff; border: none; box-shadow: 0 1px 3px rgba(33,150,211,.25); }
.btn-primary:hover { background: var(--dya-blue-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--text-2); border: 1px solid var(--border-md); }
.btn-outline:hover { background: var(--bg); color: var(--text); }
.btn-danger  { background: var(--danger-bg); color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fca5a5; }

/* "Agregar otro" — visible y claro */
.btn-agregar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .13s;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
  background: var(--accent-bg);
  color: var(--dya-blue);
  border: 1.5px solid var(--dya-blue);
  text-decoration: none;
}
.btn-agregar:hover { background: var(--dya-blue); color: #fff; }

.btn-ghost   { background: transparent; color: var(--dya-blue); border: 1px solid var(--border-md); }
.btn-ghost:hover { background: var(--accent-bg); border-color: var(--dya-blue); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-xs { padding: 3px 9px;  font-size: 11.5px; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
label {
  display: block;
  height: 42px;
  object-fit: contain;
  object-position: left; font-size: 11px; font-weight: 700;
  color: var(--text-3); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .06em;
}
input, select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border-md); border-radius: var(--radius);
  font-family: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface); transition: border-color .13s, box-shadow .13s; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--dya-blue);
  box-shadow: 0 0 0 3px rgba(33,150,211,.12);
}
textarea { resize: none; min-height: 68px; }
.form-hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-ok      { background: var(--success-bg); color: var(--success); }
.badge-cerca   { background: var(--warn-bg);    color: var(--warn); }
.badge-excedido{ background: var(--danger-bg);  color: var(--danger); }
.badge-neutral { background: #f3f4f6; color: var(--text-3); }
.badge-info    { background: var(--accent-bg);  color: var(--accent-text); }

/* ── Progress ───────────────────────────────────────────────── */
.progress-wrap { background: var(--border); border-radius: 99px; height: 5px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 99px; transition: width .3s; }
.progress-bar.ok      { background: var(--success); }
.progress-bar.cerca   { background: #f59e0b; }
.progress-bar.excedido{ background: var(--danger); }

/* ── Section header ─────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title  { font-size: 13.5px; font-weight: 700; color: var(--text); font-family: 'Inter Tight', sans-serif; }

/* ── Alertas ────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; display: flex; align-items: flex-start; gap: 9px; border-left: 3px solid; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);       border-left-color: var(--danger); }
.alert-warning { background: var(--warn-bg);    color: var(--warn);         border-left-color: #f59e0b; }
.alert-info    { background: var(--accent-bg);  color: var(--accent-text);  border-left-color: var(--dya-blue); }
.alert-success { background: var(--success-bg); color: var(--success);      border-left-color: var(--success); }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 24px; color: var(--text-3); }
.empty-state i { font-size: 34px; margin-bottom: 10px; display: block; }
.empty-state p { font-size: 13px; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 22px 22px 18px;
  width: 100%; max-width: 580px; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.18);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.modal-title  { font-size: 15px; font-weight: 700; font-family: 'Inter Tight', sans-serif; }
.modal-close  { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 18px; padding: 2px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 9px 16px; font-size: 13px; font-weight: 500; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; transition: color .13s; }
.tab.active { color: var(--dya-blue); border-bottom-color: var(--dya-blue); font-weight: 600; }
.tab:hover:not(.active) { color: var(--text-2); }

/* ── Period selector ────────────────────────────────────────── */
.period-selector { display: flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--border-md); border-radius: var(--radius); padding: 5px 10px; }
.period-selector i { color: var(--text-3); font-size: 15px; }
.period-selector select { border: none; background: transparent; padding: 0; font-size: 13px; font-weight: 500; width: auto; cursor: pointer; color: var(--text); }
.period-selector select:focus { box-shadow: none; }

/* ── Fila movimiento múltiple ───────────────────────────────── */
.mov-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 10px;
  margin-bottom: 10px;
}
.mov-row-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.mov-row-num { font-size: 10px; font-weight: 700; color: var(--dya-blue); text-transform: uppercase; letter-spacing: .08em; }

/* ── Clasif tag ─────────────────────────────────────────────── */
.clasif-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-bg); color: var(--accent-text);
  border-radius: 99px; padding: 2px 9px; font-size: 11px; font-weight: 600;
}

/* ── Utils ──────────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.justify-between { justify-content: space-between; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-12  { margin-bottom: 12px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.text-muted   { color: var(--text-2); }
.text-small   { font-size: 12px; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.hidden       { display: none !important; }
.text-blue    { color: var(--dya-blue); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }

.spinner { width: 17px; height: 17px; border: 2px solid var(--border); border-top-color: var(--dya-blue); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 36px; gap: 10px; color: var(--text-3); font-size: 13px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  #sidebar { width: 58px; }
  #sidebar .logo img, #sidebar .logo-sub, #sidebar nav a span,
  #sidebar .nav-section, #sidebar .sidebar-footer { display: none; }
  #sidebar nav a { justify-content: center; padding: 12px; border-left: none; }
  #main { margin-left: 58px; }
  #content { padding: 14px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* ── Fade entre páginas ─────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* Fade de entrada en cada página */
/* fade manejado por JS en navegación */


/* ── FIX FINAL: menú y acciones ─────────────────────────────── */
#sidebar { opacity: 1 !important; transform: none !important; transition: none !important; animation: none !important; }
#main { opacity: 1 !important; transition: none !important; animation: none !important; }
textarea { resize: none !important; }

#ultimosMovs .table-wrap,
.card .table-wrap { overflow-x: hidden; }

#ultimosMovs table,
table:has(#ultimosMovsBody),
table:has(#tablaMovs) {
  width: 100%;
  table-layout: fixed;
}

#ultimosMovsBody td,
#tablaMovs td {
  overflow: hidden;
}

#ultimosMovsBody td:nth-child(1) { width: 100px; }
#ultimosMovsBody td:nth-child(2) { width: 180px; }
#ultimosMovsBody td:nth-child(3) { width: 220px; }
#ultimosMovsBody td:nth-child(4) { width: 70px; }
#ultimosMovsBody td:nth-child(5) { width: 70px; }

#ultimosMovs th.th-actions,
#ultimosMovs td.td-actions,
#tablaMovs th.th-actions,
#tablaMovs td.td-actions {
  width: 104px !important;
  min-width: 104px !important;
  max-width: 104px !important;
  padding-left: 10px !important;
  padding-right: 26px !important;
  text-align: right !important;
  overflow: visible !important;
  white-space: nowrap !important;
}

#ultimosMovs .action-buttons,
#tablaMovs .action-buttons {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 8px !important;
  margin-right: 0 !important;
}

#ultimosMovs .btn-xs,
#tablaMovs .btn-xs {
  flex: 0 0 auto !important;
}
