:root {
  --primary: #1C1C1C;
  --primary-light: #3A3A3A;
  --secondary: #5A6470;
  --accent: #1E7145;
  --danger: #C00000;
  --warning: #B7791F;
  --bg-main: #F4F6F8;
  --bg-card: #FFFFFF;
  --text-main: #1E1E1E;
  --text-muted: #6B7280;
  --border: #DCDCDC;
  --sidebar-w: 240px;
}

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

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.4;
}

/* App Shell Layout */
#app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

/* Sidebar shown when the layout has the nav-open flag (toggled by the hamburger) */
#main-layout.nav-open .sidebar {
  transform: translateX(0);
}

/* Dark overlay behind the drawer (mobile only) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 90;
}
#main-layout.nav-open .sidebar-overlay {
  display: block;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  height: 36px;
  width: auto;
  border-radius: 4px;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #FFF;
}

.sidebar-menu {
  flex: 1;
  padding: 20px 0;
  list-style: none;
}

.sidebar-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
}

.sidebar-item a:hover,
.sidebar-item.active a {
  color: #fff;
  background: rgba(255,255,255,0.1);
  border-left: 4px solid var(--accent);
  padding-left: 20px;
}

.sidebar-item.divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 15px 20px;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-user-name {
  font-weight: 700;
  color: #fff;
  font-size: 12px;
}

/* Main Content Area */
.main-wrapper {
  margin-left: 0;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

/* On desktop, an open sidebar pushes the content instead of overlaying it */
@media (min-width: 769px) {
  #main-layout.nav-open .main-wrapper {
    margin-left: var(--sidebar-w);
  }
  .sidebar-overlay {
    display: none !important;
  }
}

/* Hamburger toggle button */
.nav-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: var(--primary);
  padding: 4px 10px;
  margin-right: 10px;
  border-radius: 6px;
}
.nav-toggle:hover {
  background: #f0f0f0;
}

.top-bar {
  background: #fff;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  border-bottom: 1px solid var(--border);
}

.top-bar-title {
  font-size: 16px;
  font-weight: 700;
}

.content-body {
  padding: 30px;
  flex: 1;
}

/* Cards & Generic Styles */
.card {
  background: var(--bg-card);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  padding: 24px;
  margin-bottom: 24px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--primary);
  border-bottom: 2px solid var(--secondary);
  padding-bottom: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-size: 12px;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: #154c2f;
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}
.btn-secondary:hover {
  background: #444c56;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #900000;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-outline:hover {
  background: #f0f0f0;
}

/* Form Styles */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #4B5563;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.2s;
  background-color: #fff;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* Tables */
table.summary-pl {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

table.summary-pl tr {
  border-bottom: 1px solid #eee;
}

table.summary-pl td {
  padding: 8px 12px;
  vertical-align: middle;
}

table.summary-pl td:last-child {
  text-align: right;
  font-weight: 600;
}

.indent-1 {
  padding-left: 24px !important;
}

.s-header {
  background: #F3F4F6;
  font-weight: 700;
  color: var(--primary);
}

.s-header td {
  padding: 6px 12px !important;
}

/* Kanban Board (Pipeline) */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 20px;
  align-items: flex-start;
}

.kanban-col {
  flex: 1;
  min-width: 250px;
  background: #E5E7EB;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 80vh;
}

.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
}

.kanban-col-title {
  font-weight: 700;
  font-size: 13px;
  color: #374151;
}

.kanban-col-count {
  background: #9CA3AF;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.kanban-cards-wrapper {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
}

.kanban-card {
  background: #fff;
  border-radius: 6px;
  padding: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  cursor: grab;
  border-left: 4px solid var(--secondary);
  transition: transform 0.2s, box-shadow 0.2s;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.kanban-card-company {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kanban-card-title {
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 6px;
}

.kanban-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* KPI Cards Layout */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border-top: 4px solid var(--secondary);
}

.kpi-card.green { border-top-color: var(--accent); }
.kpi-card.wine { border-top-color: var(--primary); }
.kpi-card.orange { border-top-color: var(--warning); }
.kpi-card.red { border-top-color: var(--danger); }

.kpi-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 18px;
  font-weight: 800;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Verdict Banner */
.verdict {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border-left: 6px solid var(--accent);
  display: flex;
  gap: 16px;
  align-items: center;
}

.verdict-icon {
  font-size: 24px;
}

.verdict-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.verdict-text {
  color: #4B5563;
  font-size: 12px;
}

/* Wizard Stepper Styling */
.wizard-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
  position: relative;
}

.wizard-steps::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 0;
  right: 0;
  height: 2px;
  background: #E5E7EB;
  z-index: 1;
}

.wizard-step {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.wizard-step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #E5E7EB;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: all 0.2s;
}

.wizard-step.active .wizard-step-circle {
  background: var(--accent);
  color: #fff;
}

.wizard-step.completed .wizard-step-circle {
  background: var(--primary);
  color: #fff;
}

.wizard-step-label {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.wizard-step.active .wizard-step-label {
  color: var(--accent);
}

.wizard-panel {
  display: none;
}

.wizard-panel.active {
  display: block;
}

/* Dynamic Add/Remove Row Tables */
.dyn-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.dyn-table th {
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
}

.dyn-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}

.pu-input, .opex-input, .param-input {
  width: 100%;
  padding: 4px 8px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  transition: all 0.2s;
}

.pu-input:focus, .opex-input:focus, .param-input:focus {
  outline: none;
  border-color: var(--accent);
  border-style: solid;
  background: #fff;
}

/* Login Layout */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#login-bg-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('/img/fondo.png') center center / cover no-repeat;
  z-index: 1;
  pointer-events: none;
}

.login-video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  z-index: 2;
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  padding: 40px;
}

.login-logo {
  display: block;
  margin: 0 auto 20px;
  height: 60px;
}

.login-title {
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 24px;
  color: var(--primary);
}

/* Two-panel login: brand collage + form */
.login-split {
  display: flex;
  width: 100%;
  max-width: 780px;
  margin: 20px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 3;
}
.login-brand {
  flex: 0 0 320px;
  background: rgba(14, 23, 38, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 26px;
  gap: 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}
.login-brand-img {
  width: 100%;
  max-width: 270px;
  height: auto;
  border-radius: 8px;
  display: block;
  box-shadow: 0 4px 18px rgba(0,0,0,0.3);
}
.login-brand-caption {
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.login-split .login-card {
  max-width: none;
  flex: 1;
  border-radius: 0;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-split .login-card .login-title {
  color: #fff;
}
.login-split .login-card .form-label {
  color: rgba(255, 255, 255, 0.85);
}
.login-split .login-card .form-control {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}
.login-split .login-card .form-control::placeholder {
  color: rgba(255, 255, 255, 0.4);
}
.login-split .login-card .form-control:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--accent);
  color: #fff;
}
.login-group-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
  background: #fff;
  padding: 8px;
  border-radius: 6px;
  max-width: 160px;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.login-group-logo img {
  max-height: 50px;
  width: auto;
  object-fit: contain;
}

/* Sidebar group logo chip (GIF is dark ink on white) */
.sidebar-group-logo {
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
}
.sidebar-group-logo img {
  max-width: 130px;
  height: auto;
  display: block;
}
/* Sidebar decorative brand banner strip */
.sidebar-banner {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 720px) {
  .login-split { flex-direction: column; max-width: 420px; }
  .login-brand { flex: 0 0 auto; padding: 18px; }
  .login-brand-img { max-width: 220px; }
  .login-group-logo img { max-height: 72px; }
}

/* Forecast Views */
.cf-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: 15px;
}

.cf-cell {
  background: #fff;
  border-radius: 6px;
  padding: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  border-top: 3px solid var(--border);
}

.cf-cell.cf-pos { border-top-color: var(--accent); }
.cf-cell.cf-neg { border-top-color: var(--danger); }

.cf-mes {
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 6px;
}

.cf-note {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.3;
}

.chart-wrap {
  position: relative;
  width: 100%;
}

/* ============================================================
   Responsive utilities & breakpoints
   ============================================================ */

/* Wrapper that lets a wide table scroll horizontally on small screens */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

/* Reusable two-column layouts that collapse on narrow screens */
.grid-2,
.grid-main {
  display: grid;
  gap: 20px;
  margin-bottom: 24px;
}
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-main { grid-template-columns: 1.1fr 0.9fr; }

/* Tablet / small laptop: stack the two-column dashboard sections */
@media (max-width: 900px) {
  .grid-2,
  .grid-main {
    grid-template-columns: 1fr;
  }
}

/* Forecast 5-month strip wraps down on smaller screens */
@media (max-width: 760px) {
  .cf-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 420px) {
  .cf-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Project Tracking Timeline ─────────────────────────────── */
.tracking-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.tracking-header h2 { margin: 0; font-size: 16px; font-weight: 800; }
.tracking-header small { font-size: 11px; color: var(--text-muted); }
.tracking-header .tracking-header-info { flex: 1; min-width: 0; }

.tracking-progress {
  margin-bottom: 28px;
}
.tracking-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}
.progress-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  display: flex;
  gap: 16px;
  padding-bottom: 20px;
  position: relative;
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot-wrap { flex-shrink: 0; padding-top: 2px; }
.timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.18s;
  position: relative;
  z-index: 1;
  user-select: none;
}
.timeline-dot:hover { border-color: var(--accent); transform: scale(1.1); }
.timeline-dot.completed { background: var(--accent); border-color: var(--accent); color: #fff; }
.timeline-dot.blocked   { background: var(--danger);  border-color: var(--danger);  color: #fff; }

.timeline-body { flex: 1; min-width: 0; }

.timeline-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color 0.15s;
}
.timeline-item[data-status="completed"] .timeline-row { border-color: var(--accent); }
.timeline-item[data-status="blocked"]   .timeline-row { border-color: var(--danger); }

.timeline-title-wrap { flex: 1; min-width: 0; }
.timeline-title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  outline: none;
  border-bottom: 1px dashed transparent;
  padding: 1px 2px;
  border-radius: 2px;
  word-break: break-word;
}
.timeline-title:focus {
  border-bottom-color: var(--accent);
  background: rgba(30,113,69,.06);
}
.timeline-title[data-status="completed"] { text-decoration: line-through; color: var(--text-muted); }

.timeline-meta {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.timeline-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: 999px;
}
.timeline-badge.pending   { background: #F3F4F6; color: var(--text-muted); }
.timeline-badge.completed { background: #D1FAE5; color: #065F46; }
.timeline-badge.blocked   { background: #FEE2E2; color: #991B1B; }
.timeline-date { font-size: 11px; color: var(--text-muted); }

.timeline-notes-text {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  outline: none;
  margin-top: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px dashed transparent;
  min-height: 18px;
  word-break: break-word;
}
.timeline-notes-text:empty::before {
  content: attr(data-placeholder);
  color: #C0C4CC;
  pointer-events: none;
}
.timeline-notes-text:focus {
  border-color: var(--border);
  background: var(--bg);
}

.timeline-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.timeline-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  transition: background 0.15s;
}
.timeline-btn:hover { background: var(--border); }
.timeline-btn.danger:hover { background: #FEE2E2; color: var(--danger); }

/* ── Collaborators panel ────────────────────────────────────── */
.collabs-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 20px;
  overflow: hidden;
}
.collabs-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  cursor: pointer;
  background: var(--bg);
  user-select: none;
  font-size: 13px;
  font-weight: 700;
}
.collabs-toggle:hover { background: var(--border); }
.collabs-chevron { margin-left: auto; font-size: 11px; color: var(--text-muted); transition: transform .2s; }
.collabs-section.open .collabs-chevron { transform: rotate(180deg); }
.collabs-body { padding: 16px; border-top: 1px solid var(--border); }

.collab-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.collab-item:last-child { border-bottom: none; }
.collab-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  flex-shrink: 0;
}
.collab-avatar.owner { background: var(--accent); }
.collab-info { flex: 1; min-width: 0; }
.collab-name { font-size: 13px; font-weight: 700; }
.collab-email { font-size: 11px; color: var(--text-muted); }

.add-collab-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.add-collab-row select { flex: 1; }

.shared-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: #EEF2FF;
  color: #4338CA;
  border-radius: 999px;
  padding: 2px 8px;
}

.drag-handle {
  cursor: grab;
  color: #C0C4CC;
  font-size: 18px;
  padding: 0 6px 0 0;
  user-select: none;
  flex-shrink: 0;
  line-height: 1.6;
  touch-action: none;
}
.drag-handle:active { cursor: grabbing; }

.timeline-item.dragging { opacity: 0.35; }
.timeline-item.drag-over-top    .timeline-row { border-top:    2px solid var(--accent); }
.timeline-item.drag-over-bottom .timeline-row { border-bottom: 2px solid var(--accent); }

.add-milestone-row {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.add-milestone-row input { flex: 1; }

/* Phone tweaks: tighter padding and scrollable wizard stepper */
@media (max-width: 600px) {
  .content-body { padding: 16px; }
  .top-bar { padding: 0 14px; }
  .card { padding: 16px; }
  .wizard-steps { overflow-x: auto; padding-bottom: 6px; }
  .wizard-step { min-width: 60px; }
  .wizard-step-label { font-size: 9px; }
  /* Let dynamic tables scroll horizontally instead of overflowing */
  .dyn-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ───────────────────────── Tracking financiero ───────────────────────── */
.progress-bar-fill.accent { background: var(--accent); }

.track-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  margin: 18px 0 18px;
}
.track-tab {
  background: transparent; border: none; cursor: pointer;
  padding: 9px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; border-radius: 6px 6px 0 0;
}
.track-tab:hover { background: var(--bg-main); color: var(--text-main); }
.track-tab.active { color: var(--primary); border-bottom-color: var(--accent); }

.track-empty {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
  border: 1px dashed var(--border); border-radius: 12px; background: var(--bg-main);
}
.track-empty h3 { margin: 8px 0 6px; color: var(--text-main); }
.track-empty p { max-width: 460px; margin: 0 auto 16px; }

.track-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.track-section-title { margin: 22px 0 10px; font-size: 13px; font-weight: 700; color: var(--primary); }

.track-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.track-kpi { background: var(--bg-main); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.track-kpi-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); letter-spacing: .03em; }
.track-kpi-value { font-size: 22px; font-weight: 800; margin: 4px 0 2px; }
.track-kpi-sub { font-size: 11px; color: var(--text-muted); }

.track-progress-wrap { margin: 20px 0 6px; }
.track-progress-row { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; margin-bottom: 5px; }

.track-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

/* Grid (Triskell-style) */
.grid-scroll { overflow-x: auto; }
.track-grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.track-grid th {
  text-align: right; padding: 9px 12px; background: var(--primary); color: #fff;
  font-size: 10px; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0;
}
.track-grid th:first-child { text-align: left; }
.track-grid td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.track-grid tbody tr:hover { background: var(--bg-main); }
.grid-group-row td { background: #EEF1F6; font-weight: 700; font-size: 10px; text-transform: uppercase; color: var(--secondary); letter-spacing: .04em; padding: 5px 12px; }
.grid-partida { font-weight: 600; }
.grid-tipo { font-size: 9px; text-transform: uppercase; padding: 1px 6px; border-radius: 999px; margin-left: 8px; vertical-align: middle; }
.grid-tipo.ingreso { background: #D1FAE5; color: #065F46; }
.grid-tipo.egreso { background: #FEE2E2; color: #991B1B; }
.grid-num { text-align: right; font-variant-numeric: tabular-nums; }
.grid-forecast.editable { cursor: text; border-radius: 4px; outline: 1px dashed transparent; }
.grid-forecast.editable:hover { background: #FFF7E6; outline-color: var(--warning); }
.grid-forecast.editable:focus { background: #FFF7E6; outline: 1px solid var(--warning); }
.grid-units { font-size: 10px; color: var(--secondary); margin-left: 8px; background: #EEF1F6; padding: 1px 7px; border-radius: 999px; }
.grid-units.warn { background: #FEF3C7; color: #92400E; }
.grid-avance { width: 130px; }
.grid-avance-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; display: inline-block; width: 80px; vertical-align: middle; margin-right: 6px; }
.grid-avance-bar span { display: block; height: 100%; border-radius: 999px; background: var(--secondary); }

/* Inventory panel */
.inv-panel { border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; background: var(--bg-card); }
.inv-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 10px; font-size: 13px; flex-wrap: wrap; }
.inv-progress { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 200px; }
.inv-progress-text { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.inv-progress-text b { font-size: 17px; color: var(--accent); }
.inv-progress-bar { width: 200px; height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.inv-progress-bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.inv-summary { font-size: 11px; color: var(--text-muted); }
.inv-summary.over { color: var(--danger); font-weight: 700; }
.inv-summary.done { color: var(--accent); font-weight: 700; }
.inv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 20px; }
.inv-row { display: grid; grid-template-columns: 1fr 70px auto auto; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0; }
.inv-name { color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.inv-bar span { display: block; height: 100%; background: var(--secondary); border-radius: 999px; }
.inv-count { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-main); white-space: nowrap; }
.inv-rem { font-size: 10px; color: var(--text-muted); white-space: nowrap; min-width: 74px; text-align: right; }
.inv-row.done .inv-bar span { background: var(--accent); }
.inv-row.done .inv-rem { color: var(--accent); }
.inv-row.over .inv-bar span { background: var(--danger); }
.inv-row.over .inv-rem { color: var(--danger); font-weight: 700; }
.unit-left { color: var(--text-muted); font-size: 10px; }
.unit-left.none { color: var(--danger); }

/* Lotes */
.lote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.lote-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--bg-card); box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.lote-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.lote-name { font-weight: 700; font-size: 14px; border: 1px solid transparent; border-radius: 6px; padding: 3px 6px; width: 100%; background: transparent; }
.lote-name:hover:not(:disabled) { border-color: var(--border); }
.lote-name:focus { border-color: var(--accent); outline: none; background: #fff; }
.lote-badge { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: #F3F4F6; color: var(--text-muted); }
.lote-badge.status-po_cliente, .lote-badge.status-po_proveedor { background: #EDE9FE; color: #5B21B6; }   /* Fase 2 compras */
.lote-badge.status-pago_proveedor { background: #FEF3C7; color: #92400E; }                                /* egreso a proveedor */
.lote-badge.status-transito, .lote-badge.status-qa_qc, .lote-badge.status-entrega { background: #DBEAFE; color: #1E40AF; } /* Fase 3 logística */
.lote-badge.status-facturado, .lote-badge.status-cobranza { background: #FEF3C7; color: #92400E; }         /* Fase 4 cuentas por cobrar */
.lote-badge.status-cerrado { background: #D1FAE5; color: #065F46; }                                        /* cierre / cobrado */
.lote-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 2px 0 12px; }
.lote-chip { font-size: 11px; background: var(--bg-main); border: 1px solid var(--border); padding: 2px 8px; border-radius: 999px; color: var(--secondary); }
.lote-sub { font-size: 10px; color: var(--text-muted); margin: 2px 0 8px; }
.lote-units-editor { margin: 10px 0; padding: 10px; background: var(--bg-main); border-radius: 8px; }
.lote-unit-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; padding: 3px 0; }
.lote-unit-row span { color: var(--secondary); }
.lote-unit-row input { width: 70px; font-size: 12px; padding: 4px 6px; }
.lote-figs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 4px 0 12px; }
.lote-figs > div { display: flex; flex-direction: column; }
.lote-figs span { font-size: 9px; text-transform: uppercase; color: var(--text-muted); }
.lote-figs b { font-size: 15px; }
.lote-bar { width: 100%; height: 7px; }
.lote-bar span { background: var(--secondary); }
.lote-avance-lbl { color: var(--text-muted); font-size: 10px; display: block; margin: 4px 0 10px; }
.lote-history { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.lote-hist-chip { font-size: 10px; background: var(--bg-main); border: 1px solid var(--border); padding: 3px 8px; border-radius: 999px; color: var(--secondary); white-space: nowrap; }
.lote-hist-chip b { color: var(--text-main); font-weight: 700; margin-left: 4px; }
.lote-controls { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.lote-controls label { font-size: 10px; color: var(--text-muted); display: flex; flex-direction: column; gap: 3px; }
.lote-controls select, .lote-controls input { font-size: 12px; padding: 4px 6px; }
.lote-advance-confirm { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding: 8px 10px; background: #FFF7E6; border: 1px solid var(--warning); border-radius: 8px; font-size: 11px; }
.lote-advance-confirm input[type="date"] { font-size: 12px; padding: 4px 6px; }
.lote-ms { margin-top: 10px; font-size: 11px; color: var(--secondary); border-top: 1px solid var(--border); padding-top: 8px; }
.lote-ms-hint { color: var(--text-muted); font-size: 10px; }

/* Movements ledger */
.mv-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; padding: 12px; background: var(--bg-main); border-radius: 10px; }
.mv-form .form-control { font-size: 12px; padding: 6px 8px; width: auto; }
.mv-form #mv-date { width: 140px; }
.mv-form #mv-partida { width: 190px; }
.mv-form #mv-lote { width: 130px; }
.mv-form #mv-tipo { width: 120px; }
.mv-form #mv-amount { width: 130px; }
.mv-form #mv-desc { flex: 1; min-width: 140px; }
.mv-tipo { font-size: 14px; }
.mv-table td { font-size: 12px; }
.mv-auto-row { background: #FbfBf6; }
.mv-auto-badge { font-size: 9px; background: #EEF1F6; color: var(--secondary); padding: 1px 6px; border-radius: 999px; margin-left: 6px; white-space: nowrap; }
.mv-date-cell { font-size: 11px; padding: 3px 5px; border: 1px solid transparent; border-radius: 4px; background: transparent; }
.mv-date-cell:hover { border-color: var(--border); }
.mv-date-cell:focus { border-color: var(--warning); outline: none; background: #FFF7E6; }
.mv-amount-cell.editable { cursor: text; border-radius: 4px; }
.mv-amount-cell.editable:hover { background: #FFF7E6; }
.mv-amount-cell.editable:focus { background: #FFF7E6; outline: 1px solid var(--warning); }
