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

:root {
  --sidebar-w: 280px;
  --sidebar-w-collapsed: 72px;
  
  /* Maritime Professional Palette */
  --navy-deep: #0a1f3d;
  --navy-primary: #1e3a5f;
  --navy-medium: #2d5a8c;
  --ocean-blue: #3b82f6;
  --ocean-light: #60a5fa;
  --ocean-pale: #dbeafe;
  
  --steel: #64748b;
  --steel-light: #94a3b8;
  --steel-pale: #cbd5e1;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f2942;
  
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --tbody-row-h: 36px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  background: var(--bg-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--bg-sidebar) 0%, #0a1e36 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  transition: var(--transition-smooth);
  position: relative;
  box-shadow: var(--shadow-xl);
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(59, 130, 246, 0.3) 50%, 
    transparent 100%
  );
}

.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar-top {
  height: 68px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.burger {
  width: 42px;
  height: 42px;
  border: none;
  background: rgba(59, 130, 246, 0.1);
  color: var(--ocean-light);
  font-size: 20px;
  cursor: pointer;
  border-radius: 10px;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 300;
}

.burger:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: scale(1.05);
}

.brand {
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar.collapsed .brand {
  display: none;
}

.nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  color: var(--steel-pale);
  margin-bottom: 6px;
  transition: var(--transition-smooth);
  position: relative;
  font-size: 14px;
  font-weight: 500;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--ocean-blue);
  border-radius: 0 3px 3px 0;
  transition: var(--transition-smooth);
}

.nav-item:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #ffffff;
  transform: translateX(4px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0.05) 100%);
  color: #ffffff;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.nav-item.active::before {
  height: 60%;
}

.icon {
  width: 24px;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  flex-shrink: 0;
}

.label {
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.sidebar.collapsed .label {
  display: none;
}

/* ========== CONTENT ========== */
.content {
  flex: 1;
  padding: 0;
  background: var(--bg-main);
  overflow-y: auto;
}

.page {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.page.active {
  display: block;
  padding: 32px;
}

/* Home: display gestionado por el bloque #page-home.active en sección dashboard */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.subtle {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 14px;
}

/* ========== PDA TITLE ========== */
.pda-titlebar {
  background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy-medium) 100%);
  color: #ffffff;
  border-radius: 16px;
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.pda-titlebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
    transparent 0%, 
    rgba(59, 130, 246, 0.1) 50%, 
    transparent 100%
  );
  pointer-events: none;
}

.pda-title {
  text-align: center;
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 20px;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

/* ========== BOX ========== */
.box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.box-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--navy-primary);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ocean-pale);
}

/* Remove border from box-title when inside vessel-header-row */
.vessel-header-row .box-title {
  margin: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* ========== VESSEL GRID ========== */
.vessel-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
}

@media (max-width: 1200px) {
  .vessel-grid {
    grid-template-columns: 1fr;
  }
}

.field-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.field-row .lbl {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.form-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.form-row .field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.field-row .row-2 {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 12px;
  align-items: center;
}

.row-inline {
  display: flex;
  gap: 12px;
  align-items: center;
}

.inline-2 {
  display: flex;
  gap: 12px;
  align-items: center;
}

.inline-imo {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ========== INPUTS ========== */
input,
select {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border-medium);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  background: var(--bg-card);
  transition: var(--transition-smooth);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--ocean-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input[readonly] {
  background: var(--ocean-pale);
  color: var(--navy-medium);
  font-weight: 500;
  cursor: not-allowed;
}

input[type="number"] {
  font-family: 'JetBrains Mono', monospace;
}

/* ========== BUTTONS ========== */
.btn {
  background: linear-gradient(135deg, var(--ocean-blue) 0%, var(--navy-medium) 100%);
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.3px;
  transition: var(--transition-smooth);
  box-shadow: var(--shadow-md);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(0);
}

.imo-status {
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 8px;
  white-space: nowrap;
  font-weight: 500;
}

.imo-status.ok {
  color: var(--success);
  font-weight: 600;
}

.imo-status.bad {
  color: var(--error);
  font-weight: 600;
}

/* ========== EXPENSES LAYOUT ========== */
.expenses-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1200px) {
  .expenses-layout {
    grid-template-columns: 1fr;
  }
}

.expenses-titlebar {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.inputs-title {
  text-align: left;
}

/* ========== TABLE ========== */
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

th {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 2px solid var(--border-medium);
  padding: 10px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--navy-primary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-align: left;
}

td {
  border-bottom: 1px solid var(--border-light);
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text-primary);
}

tbody tr {
  transition: var(--transition-smooth);
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.02);
}

tbody tr:last-child td {
  border-bottom: none;
}

#tabla tbody td:nth-child(3) {
  text-align: center;
  font-weight: 600;
  color: var(--navy-medium);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

#tabla tbody td:nth-child(4) {
  text-align: right;
  font-weight: 600;
  color: var(--navy-deep);
  padding-right: 16px;
  font-family: 'JetBrains Mono', monospace;
}

#tabla tbody tr {
  height: var(--tbody-row-h);
}

#tabla tbody td {
  vertical-align: middle;
}

/* ========== SIDE PANEL ========== */
.expenses-side {
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 0;
  height: fit-content;
}

.side-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-weight: 700;
  font-size: 11px;
  color: var(--navy-primary);
  align-items: center;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--border-light);
  border-radius: 12px 12px 0 0;
  padding: 10px 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

#sideInputs {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-light);
  border-top: none;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

.side-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  height: var(--tbody-row-h);
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  padding: 6px 10px;
  background: var(--bg-card);
  transition: var(--transition-smooth);
}

.side-row:hover {
  background: rgba(59, 130, 246, 0.02);
}

.side-row:last-child {
  border-bottom: none;
}

.side-row input,
.side-row select {
  height: calc(var(--tbody-row-h) - 12px);
  padding: 6px 10px;
  box-sizing: border-box;
  font-size: 12px;
}

.side-row input:disabled,
.side-row select:disabled {
  background: #f8fafc;
  color: var(--text-muted);
  border-color: var(--border-light);
  cursor: not-allowed;
}

/* ========== TOTALS ========== */
.totals {
  margin-top: 20px;
  display: grid;
  gap: 10px;
  max-width: 480px;
  margin-left: auto;
}

.tot-row {
  display: grid;
  grid-template-columns: 1fr 80px 170px;
  gap: 12px;
  align-items: center;
}

.tot-label {
  font-weight: 700;
  color: var(--text-secondary);
  text-align: right;
  font-size: 13px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.tot-cur {
  font-weight: 700;
  color: var(--navy-medium);
  text-align: center;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}

.tot-val {
  border: 1.5px solid var(--border-medium);
  border-radius: 10px;
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  padding: 10px 14px;
  font-weight: 700;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  color: var(--navy-deep);
  box-shadow: var(--shadow-sm);
}

.tot-total .tot-label {
  color: var(--navy-deep);
  font-size: 14px;
}

.tot-total .tot-val {
  background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy-medium) 100%);
  color: #ffffff;
  border-color: var(--navy-deep);
  box-shadow: var(--shadow-md);
  font-size: 17px;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
  background: var(--steel-pale);
  border-radius: 5px;
  border: 2px solid var(--bg-main);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--steel);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .content {
    padding: 16px;
  }
  
  .vessel-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .expenses-layout {
    grid-template-columns: 1fr;
  }
  
  .expenses-titlebar {
    grid-template-columns: 1fr;
  }
  
  .field-row,
  .form-row {
    grid-template-columns: 1fr;
  }
}


/* ===== PDA titlebar: left + center + right ===== */
.pda-titlebar { position: relative; }
.pda-titlebar-inner{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.pda-titlebar-inner .btn{
  white-space: nowrap;
  padding: 10px 16px;
  font-size: 13px;
}
.pda-titlebar-inner .pda-title{
  flex: 1;
  text-align: center;
}

/* Secondary button (same look, different tone) */
.btn.btn-secondary{
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

/* ===== Modals ===== */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
}
.modal{
  width: min(520px, 100%);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-light);
  padding: 18px 18px 16px;
}
.modal-title{
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 10px;
  color: var(--text-primary);
}
.modal-text{
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  white-space: pre-line;
}
.modal-actions{
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 14px;
}
.modal input{
  margin-top: 6px;
}
.vessel-header-row{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ocean-pale);
  margin-bottom: 20px;
}

.box-title-divider{
  height: 2px;
  background: var(--ocean-pale);
  border-radius: 2px;
  margin: 10px 0 18px;
}


.vessel-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.vessel-header .box-title{
  margin:0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ocean-pale);
  flex: 1;
}

.pda-inline{
  display:flex;
  align-items:center;
  gap: 10px;
  margin-left: 20px;
}

.pda-inline-label{
  font-weight: 700;
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  white-space: nowrap;
}

#pda_number{
  width: 90px;
  height: 30px;
  padding: 4px 10px;
  border-radius: 10px;
  text-align: center;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}
/* ===== Submenu (Sidebar) ===== */

.nav-group { margin-bottom: 6px; }

.nav-parent{
  position: relative;
  display:flex;
  align-items:center;
}

.nav-parent .chev{
  margin-left: auto;
  opacity: 0.9;
  transition: var(--transition-smooth);
}

.nav-group.open .nav-parent .chev{
  transform: rotate(90deg);
}

.nav-sub{
  margin-left: 12px;
  padding-left: 10px;
  border-left: 1px solid rgba(255,255,255,0.12);
  display: none;
}

.nav-group.open .nav-sub{
  display: block;
}

.nav-child{
  padding: 10px 14px;
  border-radius: 10px;
  margin: 4px 0;
  font-size: 13px;
}

.nav-child .icon{
  font-size: 14px;
  opacity: 0.9;
}

/* cuando sidebar está colapsado: ocultar submenú para no romper */
.sidebar.collapsed .nav-sub{
  display: none !important;
  
}
.sidebar.collapsed .nav-parent .chev{
  display: none;
}
/* ═══════════════════════════════════════════════════════
   MULTIPORT — Refined Layout
   ═══════════════════════════════════════════════════════ */

/* No panel lateral en multiport */
.mp-only-onecol {
  grid-template-columns: 1fr !important;
}

.mp-titlebar-onecol {
  grid-template-columns: 1fr !important;
}

/* ── Scroll wrapper ─────────────────────────────────── */
.mp-wrap {
  overflow-x: visible;
  overflow-y: visible;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  box-shadow: 0 1px 4px rgba(15,23,42,0.06);
  margin-top: 4px;
  width: 100%;
}

/* ── Table base ─────────────────────────────────────── */
.mp-table {
  min-width: 1520px;
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  background: #fff;
  /* Override global table styles */
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.mp-table th,
.mp-table td {
  padding: 9px 11px;
  border-bottom: 1px solid rgba(226,232,240,0.7);
  vertical-align: middle;
  font-size: 12.5px;
}

/* ── Meta rows (RATE / PORT STAY / PORT / PURPOSE) ─── */
.mp-meta {
  background: #f8fafc;
}

.mp-meta td {
  padding: 8px 11px;
  border-bottom: 1px solid rgba(226,232,240,0.5);
}

.mp-meta-label {
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background: #f1f5f9 !important;
  white-space: nowrap;
}

/* Strong bottom border after last meta row (PURPOSE) */
.mp-meta-last td {
  border-bottom: 2px solid #93c5fd;
}

/* ── Column separators between port groups ──────────── */
/*
  Estructura de columnas (DOM elements):
  · mp-meta rows     (4 tds):   label(cs2) | P1(cs3) | P2(cs3) | P3(cs3)
      → separar antes de P2=nth(3) y P3=nth(4)
  · mp-headrow       (5 tds):   desc | remarks | P1-head(cs3) | P2-head(cs3) | P3-head(cs3)
      → separar antes de P2-head=nth(4) y P3-head=nth(5)
  · mp-subheadrow    (11 tds):  … | P1-amt | P1-tar | P1-qty | P2-amt | P2-tar | P2-qty | P3-amt | …
      → separar antes de P2-amt=nth(6) y P3-amt=nth(9)
  · mp-row           (11 tds):  desc | remarks | P1-amt | P1-tar | P1-qty | P2-amt | P2-tar | P2-qty | P3-amt | …
      → separar antes de P2-amt=nth(6) y P3-amt=nth(9)
  · tfoot mp-total-row (4 tds): label(cs2) | P1(cs3) | P2(cs3) | P3(cs3)
      → separar antes de P2=nth(3) y P3=nth(4)
*/
.mp-meta td:nth-child(3),
.mp-meta td:nth-child(4) {
  border-left: 2px solid rgba(147, 197, 253, 0.70);
}

.mp-headrow td:nth-child(4),
.mp-headrow td:nth-child(5) {
  border-left: 2px solid rgba(147, 197, 253, 0.70);
}

.mp-subheadrow td:nth-child(6),
.mp-subheadrow td:nth-child(9),
.mp-row td:nth-child(6),
.mp-row td:nth-child(9) {
  border-left: 2px solid rgba(147, 197, 253, 0.70);
}

.mp-total-row td:nth-child(3),
.mp-total-row td:nth-child(4) {
  border-left: 2px solid rgba(147, 197, 253, 0.70);
}

/* ── Port header cells ──────────────────────────────── */
.mp-porthead {
  text-align: center;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--navy-primary);
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%) !important;
  border-bottom: 2px solid #93c5fd !important;
  padding: 10px 14px !important;
}

/* ── Column header row (Description / Remarks / Port headers) */
.mp-headrow td,
.mp-headrow th {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 2px solid var(--border-medium);
  padding: 9px 11px;
}

.mp-headcell {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  text-align: center;
  white-space: nowrap;
}

/* ── Subheader row (Amount / Tarifa / Cantidad) ──────── */
.mp-subheadrow td,
.mp-subheadrow th {
  background: #f8fafc;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  padding: 7px 11px;
  border-bottom: 1px solid var(--border-medium);
}

/* ── Data rows ──────────────────────────────────────── */
.mp-row {
  transition: background-color 0.12s ease;
}

.mp-row:hover {
  background: rgba(59,130,246,0.03);
}

/* Description col */
.mp-row td:first-child {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 160px;
}

/* Remarks col */
.mp-row td:nth-child(2) {
  font-size: 11.5px;
  color: var(--text-secondary);
  min-width: 120px;
}

/* ── Inputs inside table ────────────────────────────── */
.mp-input {
  width: 100%;
  min-height: 34px;
  border-radius: 7px;
  padding: 6px 10px;
  border: 1.5px solid var(--border-medium);
  background: var(--bg-card);
  font-size: 12.5px;
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.mp-input:focus {
  outline: none;
  border-color: var(--ocean-blue);
  box-shadow: 0 0 0 2.5px rgba(59,130,246,0.12);
}

.mp-input:disabled {
  background: #f8fafc;
  color: #c4cdd8;
  border-color: #e9eef4;
  cursor: not-allowed;
}

/* Remarks textarea */
.mp-remark-input {
  width: 100%;
  min-height: 32px;
  border-radius: 7px;
  padding: 5px 9px;
  border: 1.5px solid var(--border-medium);
  background: var(--bg-card);
  font-size: 11.5px;
  font-family: 'Inter', sans-serif;
  color: var(--text-secondary);
  resize: none;
  overflow: hidden;
  line-height: 1.35;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.mp-remark-input:focus {
  outline: none;
  border-color: var(--ocean-blue);
  box-shadow: 0 0 0 2.5px rgba(59,130,246,0.12);
  min-height: 56px;
}

/* Readonly (Port Stay) */
.mp-readonly {
  background: #eff6ff !important;
  color: var(--navy-medium);
  font-weight: 700;
  border-color: #bfdbfe !important;
  font-family: 'JetBrains Mono', monospace;
}

/* ── Amount cells (computed) ────────────────────────── */
.mp-amount-cell {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  text-align: right;
  color: var(--navy-primary);
  background: #f0f9ff;
  font-size: 12.5px;
  white-space: nowrap;
  min-width: 80px;
}

.mp-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  text-align: right;
  color: var(--navy-deep);
  background: #f0f9ff !important;
  border: 1.5px solid #bae6fd !important;
}

/* ── Total rows ─────────────────────────────────────── */
.mp-total-row td {
  background: #f8fafc;
  border-top: 1px solid var(--border-medium);
  border-bottom: 1px solid var(--border-light);
  padding: 11px 11px;
  font-size: 12.5px;
}

.mp-total-label {
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-align: right;
  padding-right: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.mp-total-val {
  font-weight: 700;
  text-align: right;
  padding-right: 14px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--navy-deep);
  font-size: 13px;
  background: #f0f9ff;
  white-space: nowrap;
}

/* Grand total row */
.mp-total-grand td {
  border-top: 2px solid var(--navy-primary);
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
  padding: 13px 11px;
}

.mp-total-grand .mp-total-label {
  color: var(--navy-deep);
  font-size: 12px;
}

.mp-total-grand .mp-total-val {
  color: var(--navy-deep);
  font-size: 15px;
  font-weight: 900;
  background: transparent;
}

/* ── Empty state ────────────────────────────────────── */
#mp_empty_row td {
  text-align: center;
  padding: 52px 20px;
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
  background: #fafbfc;
}

/* ── Remarks (legacy class, kept for compat) ─────────── */
.mp-remarks {
  resize: none;
  overflow: hidden;
  line-height: 1.25;
  min-height: 34px;
}
.mp-remarks.is-expanded {
  min-height: 64px;
}


/* =======================
   REPOSITORIO (TABLA)
======================= */
.repo-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}

.repo-filters-card{
  border:1px solid rgba(0,0,0,.08);
  background:#f8fafc;
  border-radius:12px;
  padding:12px;
  margin-bottom:14px;
}

.repo-filters-grid{
  display:grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr)) auto;
  gap:12px;
  align-items:end;
}

.repo-filter-label{
  font-size:12px;
  color:var(--text-muted, #6b7280);
  margin-bottom:6px;
  letter-spacing:.02em;
}

.repo-filter input,
.repo-filter select{
  width:100%;
  height:38px;
  border-radius:10px;
  border:1px solid rgba(0,0,0,.12);
  padding:0 12px;
  background:#fff;
}

.repo-filter-actions{
  display:flex;
  justify-content:flex-end;
}

.repo-table-wrap{
  border-radius:12px;
  overflow:visible;
  border:1px solid rgba(0,0,0,.08);
}

.repo-table{
  width:100%;
  border-collapse:collapse;
}

.repo-table thead th{
  background:#0b2343;
  color:#fff;
  font-size:12px;
  text-transform:uppercase;
  padding:12px 10px;
  text-align:left;
  white-space:nowrap;
}

.repo-table tbody td{
  padding:12px 10px;
  border-top:1px solid rgba(0,0,0,.06);
  font-size:13px;
  vertical-align:middle;
}

.repo-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height:26px;
  padding:0 10px;
  border-radius:999px;
  font-size:12px;
  border:1px solid #f6d18b;
  background:#fff7e6;
  color:#1f2937;
}

/* Repo: acciones estilo link (más compacto que botones) */
.repo-actions{
  display:flex;
  align-items:center;
  gap:8px;
  white-space:nowrap;
}
.repo-link{
  color:#1f5fd6;
  font-weight:700;
  text-decoration:none;
}
.repo-link:hover{ text-decoration:underline; }
.repo-sep{ color:#7c8aa3; }
.repo-link.is-disabled{
  color:#a8b2c4;
  pointer-events:none;
  text-decoration:none;
  font-weight:600;
}

@media (max-width: 1200px){
  .repo-filters-grid{ grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}

/* ===== Repositorio: tabla responsive ===== */
.repo-table-wrap{
  width: 100%;
  overflow-x: visible;
  border-radius: 14px;
}

/* evita que se "rompa" el header y quede limpio */
.repo-table{
  width: 100%;
  min-width: unset;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

/* Header fijo al scrollear dentro del wrap */
.repo-table thead th{
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Compactar un poco (sin perder look) */
.repo-table th,
.repo-table td{
  white-space: nowrap;
  padding: 8px 5px;
  font-size: 10.5px;
}

/* Botones dentro de tabla: más compactos */
.repo-table .btn,
.repo-table button{
  padding: 10px 14px;
  font-size: 13px;
  border-radius: 12px;
}

/* ===== Ajustes por tamaño de pantalla ===== */
@media (max-width: 1400px){
  .repo-table{ min-width: unset; }
  .repo-table th, .repo-table td{ padding: 10px 10px; font-size: 13px; }
  .repo-table .btn, .repo-table button{ padding: 9px 12px; font-size: 12px; }
}

@media (max-width: 1200px){
  .repo-table{ min-width: unset; }
  .repo-table th, .repo-table td{ padding: 9px 9px; font-size: 12.5px; }
}
.page{
  width: 100%;
  max-width: 100%;
}

.page-content{
  width: 100%;
  max-width: 100%;
}

/* =========================================================
   REPOSITORIO – Densidad “tipo zoom 70%” (solo en esta página)
   ========================================================= */

#page-repositorio .card{
  padding: 18px;              /* antes 24px */
}

/* menos aire en header */
#page-repositorio .repo-header{
  margin-bottom: 10px;
}

/* filtros más compactos */
#page-repositorio .repo-filters-card{
  padding: 14px;
  margin-bottom: 14px;
}

#page-repositorio .repo-filter-label{
  font-size: 11px;
  letter-spacing: .5px;
}

#page-repositorio input,
#page-repositorio select{
  height: 40px;
  font-size: 13px;
  padding: 0 12px;
}

/* tabla sin scroll — se adapta al ancho disponible */
#page-repositorio .repo-table-wrap{
  width: 100%;
  overflow-x: visible;
  border-radius: 14px;
}

#page-repositorio .repo-table{
  width: 100%;
  min-width: unset;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

#page-repositorio .repo-table th,
#page-repositorio .repo-table td{
  padding: 8px 5px;
  font-size: 10.5px;
  white-space: nowrap;
}

/* header fijo */
#page-repositorio .repo-table thead th{
  position: sticky;
  top: 0;
  z-index: 2;
}

/* botones compactos */
#page-repositorio .repo-table button,
#page-repositorio .repo-table .btn{
  padding: 5px 8px;
  font-size: 10.5px;
  border-radius: 8px;
  white-space: nowrap;
}

/* reduce un poco el padding del área central (solo repositorio) */
#page-repositorio{
  margin: 0;
}

/* si quieres ganar ancho real del contenido sin tocar el resto */
@media (min-width: 1200px){
  #page-repositorio .card{
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ================= LOGIN SaaS ================= */

.login-page{
  position:fixed;
  inset:0;
  background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy-primary) 100%);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 9999;
}

.login-wrapper{
  width:100%;
  max-width: 420px;
  padding: 20px;
}

.login-card{
  background:#fff;
  border-radius: 18px;
  padding: 40px 36px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.25);
  text-align:center;
}

.login-brand{ margin-bottom: 28px; }
.login-logo{ width: 150px; margin-bottom: 14px; }

.login-brand h1{
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 6px 0;
  color: #0f172a;
  letter-spacing: 0.2px;
}
.login-brand p{
  font-size: 13px;
  margin: 0;
  color: #64748b;
}

.login-form{ text-align:left; }
.login-field{ margin-bottom: 16px; }
.login-field label{
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  display:block;
  margin-bottom: 6px;
}
.login-field input{
  width:100%;
  height: 44px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  padding: 0 14px;
  font-size: 14px;
  transition: all .2s ease;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.login-field input:focus{
  outline:none;
  border-color:#3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.login-btn{
  width:100%;
  height: 46px;
  border-radius: 12px;
  border:none;
  background: linear-gradient(135deg, var(--navy-primary) 0%, #3b82f6 100%);
  color:#fff;
  font-weight: 700;
  font-size: 14px;
  margin-top: 6px;
  cursor:pointer;
  transition: all .2s ease;
}
.login-btn:hover{
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(59,130,246,0.28);
}

.login-error{
  color:#ef4444;
  font-size: 12px;
  margin-top: 12px;
  text-align:center;
  min-height: 16px;
}

.login-footer{
  margin-top: 26px;
  font-size: 11px;
  color:#94a3b8;
  text-align:center;
}


/* ===== Vessel picker (IMO help) ===== */
.btn-help{
  padding: 10px 12px;
  width: 42px;
  min-width: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border-radius: 10px;
}
.modal.modal-vessel{
  width: min(720px, 100%);
}
.vessel-pick-head{
  display: grid;
  grid-template-columns: 1fr 140px 54px;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 800;
  color: var(--navy-primary);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.vessel-pick-list{
  margin-top: 10px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
}
.vessel-pick-row{
  display: grid;
  grid-template-columns: 1fr 140px 54px;
  gap: 10px;
  align-items: center;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-light);
  background: #fff;
}
.vessel-pick-row:last-child{
  border-bottom: none;
}
.vessel-pick-row:hover{
  background: rgba(59, 130, 246, 0.03);
}
.vessel-pick-vessel{
  font-weight: 600;
  color: var(--text-primary);
}
.vessel-pick-imo{
  font-family: 'JetBrains Mono', monospace;
  color: var(--navy-deep);
  font-weight: 700;
  text-align: right;
}
.vessel-pick-check{
  display:flex;
  justify-content:center;
}
.vessel-pick-check input{
  width: 18px;
  height: 18px;
}
/* ═══════════════════════════════════════════════════════════════════
   HOME DASHBOARD — Maritime Operations
   ═══════════════════════════════════════════════════════════════════ */

/* ── Page layout ─────────────────────────────────────────────────── */
#page-home.active {
  padding: 24px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ── Page header ─────────────────────────────────────────────────── */
.hd-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.hd-page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.4px;
  margin: 0 0 2px;
  line-height: 1.2;
}

.hd-period {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.hd-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hd-last-update {
  font-size: 11px;
  color: var(--text-muted);
}

.hd-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.hd-refresh-btn:hover {
  background: var(--ocean-pale);
  border-color: var(--ocean-blue);
  color: var(--ocean-blue);
}

.hd-status-msg {
  font-size: 13px;
  color: var(--text-muted);
  min-height: 16px;
}

/* ── KPI Row (8 cards) ───────────────────────────────────────────── */
.hd-kpi-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 12px;
}

.hd-kpi-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 14px 14px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  box-shadow: 0 1px 3px rgba(15,23,42,0.06), 0 4px 12px rgba(15,23,42,0.04);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  animation: hdCardIn 0.5s ease both;
}

.hd-kpi-card:hover {
  box-shadow: 0 4px 20px rgba(15,23,42,0.10);
  transform: translateY(-2px);
}

.hd-kpi-card:nth-child(1) { animation-delay: 0.04s; }
.hd-kpi-card:nth-child(2) { animation-delay: 0.08s; }
.hd-kpi-card:nth-child(3) { animation-delay: 0.12s; }
.hd-kpi-card:nth-child(4) { animation-delay: 0.16s; }
.hd-kpi-card:nth-child(5) { animation-delay: 0.20s; }
.hd-kpi-card:nth-child(6) { animation-delay: 0.24s; }
.hd-kpi-card:nth-child(7) { animation-delay: 0.28s; }
.hd-kpi-card:nth-child(8) { animation-delay: 0.32s; }

@keyframes hdCardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* Icon blobs */
.hd-kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hd-icon-blue   { background: rgba(59,130,246,0.10);  color: #3b82f6; }
.hd-icon-teal   { background: rgba(13,148,136,0.10);  color: #0d9488; }
.hd-icon-amber  { background: rgba(245,158,11,0.10);  color: #f59e0b; }
.hd-icon-rose   { background: rgba(244,63,94,0.10);   color: #f43f5e; }
.hd-icon-violet { background: rgba(139,92,246,0.10);  color: #8b5cf6; }

.hd-kpi-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.hd-kpi-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.hd-kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.15;
  white-space: nowrap;
}

.hd-kpi-value--sm {
  font-size: 14px;
  line-height: 1.3;
}

.hd-kpi-sub {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Diff card color states */
.hd-kpi-card.kpi-positive .hd-kpi-value { color: #10b981; }
.hd-kpi-card.kpi-negative .hd-kpi-value { color: #f43f5e; }

/* Ring card */
.hd-kpi-card--ring { gap: 10px; }

.hd-ring-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  flex-shrink: 0;
}

.hd-ring-svg { width: 58px; height: 58px; }

.hd-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hd-ring-label b {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.hd-ring-label span {
  font-size: 8px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

/* ── Chart cards ─────────────────────────────────────────────────── */
.hd-chart-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(15,23,42,0.06), 0 4px 12px rgba(15,23,42,0.04);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hd-chart-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.hd-chart-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
}

.hd-chart-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.hd-chart-body {
  position: relative;
}

.hd-charts-row--2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Tables row ──────────────────────────────────────────────────── */
.hd-tables-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.hd-table-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 18px 16px 12px;
  box-shadow: 0 1px 3px rgba(15,23,42,0.06);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.hd-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.hd-table thead th {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0 6px 8px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  background: transparent;
}

.hd-table thead th.num { text-align: right; }

.hd-table tbody tr { transition: background 0.15s ease; }
.hd-table tbody tr:hover { background: rgba(59,130,246,0.03); }

.hd-table tbody td {
  padding: 7px 6px;
  border-bottom: 1px solid rgba(226,232,240,0.5);
  color: var(--text-secondary);
  vertical-align: middle;
}

.hd-table tbody tr:last-child td { border-bottom: none; }

.hd-table td.num {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  white-space: nowrap;
}

.hd-table td.usd {
  color: var(--navy-primary);
  font-weight: 600;
  white-space: nowrap;
}

/* Primera columna (nombre): truncar con ellipsis */
.hd-table tbody td:first-child {
  max-width: 0;
  width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Barra mini — columna fija angosta */
.hd-table td:last-child {
  width: 44px;
  padding-right: 2px;
}

/* Rank badge */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--ocean-pale);
  color: var(--ocean-blue);
  font-size: 9px;
  font-weight: 800;
  margin-right: 5px;
  flex-shrink: 0;
  vertical-align: middle;
}

/* Inline bar */
.bar-cell {
  width: 52px;
  height: 4px;
  background: rgba(148,163,184,0.15);
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 2px;
  transition: width 0.9s cubic-bezier(0.4,0,0.2,1);
}

.bar-fill.accent2 {
  background: linear-gradient(90deg, #0d9488, #2dd4bf);
}

/* subtle inside hd-table */
.hd-table .subtle {
  color: var(--text-muted);
  font-style: italic;
  padding: 14px 6px;
  font-size: 12px;
}

/* ── Period Filter Bar ──────────────────────────────────────────── */
.hd-filter-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 10px 18px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.hd-filter-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hd-filter-icon {
  color: var(--steel-light);
  flex-shrink: 0;
}

.hd-filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.hd-month-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 3px 4px;
}

.hd-nav-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.hd-nav-btn:hover {
  background: var(--ocean-pale);
  color: var(--ocean-blue);
}

.hd-month-chip {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 120px;
  text-align: center;
  letter-spacing: 0.2px;
  padding: 0 4px;
}

.hd-filter-presets {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.hd-filter-sep {
  width: 1px;
  height: 20px;
  background: var(--border-light);
  margin: 0 3px;
  flex-shrink: 0;
}

.hd-preset-btn {
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
  line-height: 1.4;
}

.hd-preset-btn:hover {
  background: var(--ocean-pale);
  border-color: var(--ocean-blue);
  color: var(--ocean-blue);
}

.hd-preset-btn.active {
  background: var(--ocean-blue);
  border-color: var(--ocean-blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.28);
}

/* Botón Histórico — variante especial con icono de reloj */
.hd-preset-btn--history {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  border-color: var(--border-medium);
}
.hd-preset-btn--history.active {
  background: #0d9488;
  border-color: #0d9488;
  color: #fff;
  box-shadow: 0 2px 8px rgba(13,148,136,0.28);
}
.hd-preset-btn--history:hover:not(.active) {
  color: #0d9488;
  border-color: #0d9488;
  background: rgba(13,148,136,0.07);
}

/* Botón Limpiar filtro — siempre visible, acción secundaria */
.hd-filter-reset {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px dashed var(--border-medium);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
  margin-left: 0;
  letter-spacing: 0.1px;
}
.hd-filter-reset:hover {
  color: #f43f5e;
  border-color: #f43f5e;
  border-style: solid;
  background: rgba(244,63,94,0.06);
}

/* ── Drill badge ────────────────────────────────────────────────── */
.hd-drill-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: linear-gradient(135deg, rgba(59,130,246,0.08) 0%, rgba(13,148,136,0.06) 100%);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.hd-drill-type-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  background: var(--ocean-blue);
  color: #fff;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.hd-drill-badge b {
  color: var(--text-primary);
  font-size: 13px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hd-drill-clear {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 4px;
  padding: 4px 11px;
  background: transparent;
  border: 1px solid var(--border-medium);
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}
.hd-drill-clear:hover {
  border-color: var(--ocean-blue);
  color: var(--ocean-blue);
  background: var(--ocean-pale);
}

/* Clickable table rows for drill */
.tr-clickable {
  cursor: pointer;
  transition: background 0.12s;
}
.tr-clickable:hover {
  background: rgba(59,130,246,0.05) !important;
}
.tr-drill-active {
  background: rgba(59,130,246,0.10) !important;
  border-left: 2.5px solid var(--ocean-blue);
}

/* ── Chart empty state ──────────────────────────────────────────── */
.hd-chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-card);
  border-radius: 10px;
}

/* ── Responsive ──────────────────────────────────────────────────── */

/* Pantallas grandes (iMac / monitor externo) */
@media (max-width: 1700px) {
  .hd-kpi-row { grid-template-columns: repeat(4, 1fr); }
}

/* Notebook grande / laptop 15" (1440–1600px) */
@media (max-width: 1500px) {
  :root { --sidebar-w: 240px; }
  #page-home.active { padding: 18px 22px 32px; gap: 14px; }
  .hd-kpi-value { font-size: 19px; }
  .hd-kpi-card  { padding: 11px 12px; gap: 9px; }
  .hd-kpi-icon  { width: 32px; height: 32px; }
  .hd-chart-card  { padding: 14px 16px; gap: 11px; }
  .hd-table-card  { padding: 14px 14px 10px; gap: 10px; }
  .hd-charts-row--2col { gap: 14px; }
  .hd-tables-row       { gap: 14px; }
}

/* Notebook estándar / laptop 13–14" (1280–1440px) */
@media (max-width: 1400px) {
  :root { --sidebar-w: 220px; }
  #page-home.active { padding: 14px 18px 28px; gap: 12px; }
  .hd-kpi-value { font-size: 17px; }
  .hd-kpi-label { font-size: 9.5px; }
  .hd-kpi-sub   { font-size: 9px; }
  .hd-kpi-card  { padding: 10px 11px; gap: 8px; border-radius: 12px; }
  .hd-kpi-icon  { width: 30px; height: 30px; border-radius: 8px; }
  .hd-chart-card  { padding: 12px 14px; gap: 10px; border-radius: 13px; }
  .hd-chart-header h3 { font-size: 13px; }
  .hd-table-card  { padding: 12px 12px 8px; gap: 8px; border-radius: 13px; }
  .hd-tables-row  { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .hd-charts-row--2col { gap: 12px; }
  .hd-kpi-row { gap: 10px; }
}

@media (max-width: 1200px) {
  .hd-kpi-row          { grid-template-columns: repeat(4, 1fr); }
  .hd-charts-row--2col { grid-template-columns: 1fr; }
  .hd-tables-row       { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  #page-home.active { padding: 16px; gap: 14px; }
  .hd-kpi-row    { grid-template-columns: repeat(2, 1fr); }
  .hd-tables-row { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — tablet 1024px
   ══════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  :root { --sidebar-w: 220px; }
  .hd-kpi-row { grid-template-columns: repeat(4, 1fr); }
  .hd-charts-row--2col { grid-template-columns: 1fr; }
  .hd-tables-row { grid-template-columns: repeat(2, 1fr); }
  .vessel-grid { grid-template-columns: 1fr; }
  .v-right { border-left: none; border-top: 1px solid var(--border-light); padding-left: 0; padding-top: 14px; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 72px; }
  .brand { display: none; }
  .label { display: none; }
  .nav-sub { display: none !important; }
  .sidebar .sidebarUserInfo { display: none; }
  .hd-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .hd-tables-row { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .hd-filter-presets { flex-wrap: wrap; gap: 4px; }
}

@media (max-width: 600px) {
  .hd-kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .pda-titlebar-inner { flex-direction: column; gap: 8px; align-items: stretch; }
  .pda-titlebar-inner .btn { width: 100%; text-align: center; }
  .modal { width: 96vw !important; max-width: 96vw !important; }
  .repo-filters { flex-direction: column; }
  .hd-page-header { flex-direction: column; gap: 10px; }
}

/* ══════════════════════════════════════════════════════
   BUTTON LOADING STATE
   ══════════════════════════════════════════════════════ */
.btn .btn-spinner {
  display: none;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.btn:disabled {
  cursor: not-allowed;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════════════════
   PRINT STYLES — PDF-friendly
   ══════════════════════════════════════════════════════ */
@media print {
  .sidebar, .pda-titlebar, .hd-filter-bar, .hd-refresh-btn,
  .btn, .nav, .modal-backdrop { display: none !important; }
  .content { padding: 0; margin: 0; }
  .app { display: block; }
  body { background: white; }
}


/* ══════════════════════════════════════════════════════
   RESPONSIVE — Todos los tamaños de pantalla
   ══════════════════════════════════════════════════════ */

/* ── Componentes solo móvil (ocultos en desktop) ── */
.mobile-topbar  { display: none; }
.sidebar-overlay { display: none; }

/* ─────────────────────────────────────────────────────
   TABLET  (≤ 1024px)
───────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }

  .page.active { padding: 20px; }

  .pda-titlebar-inner {
    flex-wrap: wrap;
    gap: 8px;
  }
  .pda-titlebar-inner .btn {
    font-size: 12px;
    padding: 8px 12px;
  }

  /* Tablas del dashboard rendición: scroll horizontal */
  #rendTable {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ─────────────────────────────────────────────────────
   MÓVIL  (≤ 768px)
───────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* ── Layout raíz ── */
  .app {
    flex-direction: column;
  }

  /* ── Topbar móvil ── */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-sidebar);
    position: sticky;
    top: 0;
    z-index: 500;
    box-shadow: 0 2px 12px rgba(0,0,0,0.35);
    flex-shrink: 0;
  }
  .mobile-burger {
    width: 38px;
    height: 38px;
    border: none;
    background: rgba(59,130,246,0.15);
    color: #60a5fa;
    font-size: 20px;
    cursor: pointer;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .mobile-logo {
    height: 30px;
    width: auto;
    max-width: 90px;
    object-fit: contain;
  }
  .mobile-title {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ── Sidebar: overlay deslizable ── */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px !important;
    z-index: 600;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Cancelar colapso de desktop */
    display: flex !important;
  }
  .sidebar .label  { display: block !important; }
  .sidebar .brand  { display: block !important; }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* ── Overlay oscuro detrás del sidebar ── */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 599;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.visible { display: block; }

  /* ── Contenido toma todo el ancho ── */
  .content {
    width: 100%;
    overflow-x: hidden;
  }

  /* ── Páginas ── */
  .page.active { padding: 14px; }

  /* ── Header de sección (pda-titlebar) ── */
  .pda-titlebar {
    border-radius: 12px;
    padding: 16px;
  }
  .pda-titlebar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .pda-title {
    font-size: 14px;
    letter-spacing: 1px;
  }
  .pda-titlebar-inner .btn {
    width: 100%;
    justify-content: center;
    font-size: 13px;
    padding: 10px 14px;
  }

  /* ── Cards ── */
  .card { padding: 14px; border-radius: 12px; }
  .box  { padding: 14px; border-radius: 12px; }

  /* ── Grids a columna única ── */
  .vessel-grid,
  .expenses-layout {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .field-row,
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 6px;
  }

  /* ── Tablas: scroll horizontal ── */
  .table-wrap,
  #rendTable,
  #adminUsersTable,
  #tablaGastos,
  #tablaIngresos,
  #tablaRemuneraciones {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Modales: hoja desde abajo ── */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 92vh;
    overflow-y: auto;
    padding: 20px 16px 32px;
  }

  /* ── Detail panel (modal rendición) ── */
  #rendDetailPanel > div {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
  }

  /* ── Selector RBD ── */
  #rendRbdSelectorWrap { width: 100%; }

  /* ── Botones de acción alineados ── */
  .modal-actions {
    flex-direction: column;
    gap: 8px;
  }
  .modal-actions .btn {
    width: 100%;
  }

  /* ── Formularios en modal con grid a 1 col ── */
  .modal div[style*="grid-template-columns:1fr 1fr"],
  .modal div[style*="grid-template-columns: 1fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px;
  }

  /* ── Botón de establecimiento ── */
  div[style*="grid-template-columns:1fr auto"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Barra de selector de rendición ── */
  #rendRbdSearchInput { font-size: 14px; }

  /* ── Subtítulo de rendición ── */
  #rendSubtitle { font-size: 13px; }
}

/* ─────────────────────────────────────────────────────
   TELÉFONO PEQUEÑO  (≤ 480px)
───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .page.active { padding: 10px; }

  .pda-title { font-size: 12px; }

  .btn {
    font-size: 12px;
    padding: 9px 12px;
  }

  th { font-size: 10px; padding: 7px 7px; }
  td { font-size: 12px; padding: 6px 7px; }

  .card, .box { padding: 10px; }

  .mobile-title { display: none; }

}
