:root {
  --ftl-blue: #0E4F5F;
  --ftl-blue-dark: #0A3A47;
  --ftl-blue-light: #1A6B7F;
  --ftl-green: #84CC16;
  --ftl-green-dark: #65A30D;
  --ftl-green-light: #A3E635;
  --bg: #F8FAFC;
  --bg-white: #FFFFFF;
  --text: #1E293B;
  --text-secondary: #4B5563;
  --border: #E2E8F0;
  --amber: #F59E0B;
  --amber-bg: #FFFBEB;
  --amber-border: #FDE68A;
  --purple: #8B5CF6;
  --red: #EF4444;
  --sidebar-w: 280px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
a { color: var(--ftl-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== FOCUS INDICATORS ===== */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ftl-green); outline-offset: 2px; }
.sidebar :focus-visible { outline-color: var(--ftl-green-light); }
.hamburger:focus-visible { outline-color: var(--ftl-green); outline-offset: 3px; }
.bpmn-node:focus-visible { outline: 2px solid var(--ftl-green); outline-offset: 2px; border-color: var(--ftl-green); }
.cp-pip:focus-visible { outline: none; }
.cp-pip:focus-visible .cp-pip-dot { outline: 2px solid var(--ftl-blue); outline-offset: 2px; }

/* ===== LAYOUT ===== */
.shell { min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar { background: var(--ftl-blue-dark); color: #fff; position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh; overflow-y: auto; z-index: 100; display: flex; flex-direction: column; }
.sidebar-brand { padding: 28px 20px 24px; border-bottom: 1px solid rgba(255,255,255,.1); background: linear-gradient(180deg, rgba(132,204,22,.08) 0%, transparent 100%); }
.sidebar-brand h1 { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.sidebar-brand span { color: var(--ftl-green); font-size: 24px; letter-spacing: -1px; }
.sidebar-brand p { font-size: 11px; color: rgba(255,255,255,.65); margin-top: 6px; letter-spacing: .3px; }
.sidebar nav { flex: 1; padding: 12px 0; }
.nav-group-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,.55); padding: 16px 20px 6px; }
.nav-link { display: block; padding: 8px 20px 8px 24px; font-size: 13px; color: rgba(255,255,255,.85); cursor: pointer; border-left: 3px solid transparent; transition: all .15s; width: 100%; text-align: left; background: none; border-right: none; border-top: none; border-bottom: none; font-family: inherit; }
.nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-link:active { background: rgba(255,255,255,.12); }
.nav-link.active { color: #fff; background: rgba(255,255,255,.08); border-left-color: var(--ftl-green); font-weight: 600; }
.nav-link.sub { padding-left: 40px; font-size: 12px; }
.nav-toggle { cursor: pointer; display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: none; color: rgba(255,255,255,.6); font-family: inherit; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; padding: 16px 20px 6px; transition: color .15s; }
.nav-toggle:hover { color: rgba(255,255,255,.8); }
.nav-toggle::after { content: '\25BC'; font-size: 8px; transition: transform .2s; }
.nav-toggle.collapsed::after { transform: rotate(-90deg); }
.nav-children { overflow: hidden; transition: max-height .25s ease; max-height: 500px; }
.nav-children.collapsed { max-height: 0; }
.hamburger { display: none; position: fixed; top: 12px; left: 12px; z-index: 200; background: var(--ftl-blue); color: #fff; border: none; border-radius: 6px; width: 40px; height: 40px; font-size: 20px; cursor: pointer; }
.sidebar-backdrop { display: none; }

/* ===== MAIN ===== */
.main { margin-left: var(--sidebar-w); padding: 32px 40px 60px; max-width: 1100px; }
.page-section { display: none; }
.page-section.active { display: block; animation: pageIn .3s ease-out; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } }
.page-title { font-size: 32px; font-weight: 700; margin-bottom: 6px; color: var(--ftl-blue-dark); letter-spacing: -.5px; line-height: 1.2; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 32px; }
.section-heading { font-size: 18px; font-weight: 700; margin: 32px 0 16px; padding-left: 12px; border-left: 3px solid var(--ftl-blue); color: var(--ftl-blue-dark); line-height: 1.3; }
.section-heading.first { margin-top: 0; }

/* ===== PIPELINE INDICATOR ===== */
.cp-pipeline { display: flex; align-items: center; gap: 0; margin-bottom: 24px; padding: 14px 20px; background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.cp-pip { display: flex; align-items: center; gap: 0; cursor: pointer; }
.cp-pip-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: var(--text-secondary); transition: all .2s ease; background: var(--bg-white); position: relative; z-index: 1; }
.cp-pip-dot:hover { border-color: var(--ftl-blue-light); color: var(--ftl-blue); transform: scale(1.15); }
.cp-pip.done .cp-pip-dot { border-color: var(--ftl-blue); background: var(--ftl-blue); color: #fff; }
.cp-pip.current .cp-pip-dot { border-color: var(--ftl-green); background: var(--ftl-green-dark); color: #fff; transform: scale(1.2); box-shadow: 0 0 0 3px rgba(132,204,22,.2); }
.cp-pip-line { width: 16px; height: 2px; background: var(--border); flex-shrink: 0; transition: background .2s; }
.cp-pip-line-done { background: var(--ftl-blue); }
.cp-pip-label { position: absolute; top: 32px; left: 50%; transform: translateX(-50%); font-size: 9px; color: var(--text-secondary); white-space: nowrap; opacity: 0; transition: opacity .15s; pointer-events: none; font-weight: 500; }
.cp-pip:hover .cp-pip-label { opacity: 1; }
.cp-pip.current .cp-pip-label { opacity: 1; color: var(--ftl-green-dark); font-weight: 600; }

/* ===== COMPONENTS ===== */
.card { background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; transition: box-shadow .2s ease, transform .2s ease; }
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.card p { font-size: 14px; color: var(--text-secondary); }
.card p + p { margin-top: 8px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 24px; }
.card-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.badge-object { background: #DBEAFE; color: #1E40AF; }
.badge-transform { background: #FEF3C7; color: #92400E; }
.badge-aggregation { background: #EDE9FE; color: #6D28D9; }
.badge-shipping { background: #D1FAE5; color: #065F46; }
.badge-status { padding: 4px 12px; font-size: 12px; border-radius: 6px; }
.badge-completada { background: #D1FAE5; color: #065F46; }
.badge-pendiente { background: #FEF3C7; color: #92400E; }
.badge-bloqueado { background: #FEE2E2; color: #991B1B; }

.callout { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; font-size: 13px; display: flex; align-items: flex-start; gap: 10px; border-left: 4px solid transparent; }
.callout-warn { background: var(--amber-bg); border: 1px solid var(--amber-border); border-left: 4px solid var(--amber); color: #92400E; }
.callout-info { background: #EFF6FF; border: 1px solid #BFDBFE; border-left: 4px solid #3B82F6; color: #1E40AF; }
.callout-icon { font-size: 18px; flex-shrink: 0; margin-top: 0; }
code { font-family: 'Courier New', monospace; font-size: .9em; background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 3px; }
.callout code { background: rgba(0,0,0,.08); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th { background: #EDF5F7; font-weight: 700; text-align: left; padding: 10px 14px; border-bottom: 2px solid var(--ftl-blue); color: var(--ftl-blue-dark); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
table td { padding: 9px 14px; border-bottom: 1px solid var(--border); transition: background .12s ease; }
.campos-table td:first-child { font-family: 'Courier New', monospace; font-size: 12px; color: var(--ftl-blue); font-weight: 500; }
table tr:hover td { background: #EDF5F7; }
.table-wrap { overflow-x: auto; }

.cp-header { display: flex; align-items: center; gap: 20px; margin-bottom: 12px; padding: 20px 24px; background: var(--bg-white); border: 1px solid var(--border); border-left: 4px solid var(--ftl-blue); border-radius: var(--radius); box-shadow: var(--shadow); flex-wrap: wrap; }
.cp-num { width: 64px; height: 64px; border-radius: 50%; background: var(--ftl-blue); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; flex-shrink: 0; box-shadow: 0 2px 8px rgba(14,79,95,.25); }
.cp-name { font-size: 26px; font-weight: 700; color: var(--ftl-blue-dark); letter-spacing: -.3px; line-height: 1.2; }
.endpoint-card { background: #F0FDF4; border: 1px solid #BBF7D0; border-left: 4px solid var(--ftl-green-dark); border-radius: var(--radius); padding: 14px 18px; font-family: 'Courier New', monospace; font-size: 13px; margin-bottom: 20px; }
.endpoint-method { background: var(--ftl-green-dark); color: #fff; padding: 3px 10px; border-radius: 4px; font-size: 11px; font-weight: 700; margin-right: 10px; letter-spacing: .3px; }
.epcis-card { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.epcis-item { font-size: 13px; }
.epcis-label { font-weight: 600; color: var(--text-secondary); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.diagram-caption { text-align: center; font-size: 12px; color: var(--text-secondary); margin-top: 12px; }
.card-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-header-row h3 { margin: 0; }

/* ===== BPMN FLOW ===== */
.bpmn { display: flex; flex-direction: column; gap: 8px; margin-bottom: 32px; }
.bpmn-row { display: flex; align-items: center; gap: 0; flex-wrap: nowrap; overflow-x: auto; padding: 8px 0; }
.bpmn-node { background: var(--bg-white); border: 2px solid var(--ftl-blue); border-radius: 10px; padding: 12px 14px; min-width: 130px; text-align: center; flex-shrink: 0; box-shadow: var(--shadow); cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.bpmn-node:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--ftl-green); }
.bpmn-node:active { transform: translateY(0px); }
.bpmn-node.rollo { border-color: var(--amber); }
.bpmn-node.rollo:hover { border-color: var(--ftl-green); }
.bpmn-cp { display: block; font-size: 11px; font-weight: 700; color: var(--ftl-blue); }
.bpmn-name { display: block; font-size: 12px; font-weight: 600; margin: 4px 0; }
.bpmn-node .badge { font-size: 9px; padding: 2px 6px; }
.bpmn-arrow { width: 36px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; }
.bpmn-arrow::before { content: ''; width: 24px; height: 2px; background: var(--ftl-blue); }
.bpmn-arrow::after { content: ''; border: 5px solid transparent; border-left-color: var(--ftl-blue); position: absolute; right: 2px; }
.bpmn-connector { display: flex; justify-content: center; height: 24px; position: relative; font-size: 0; color: transparent; }
.bpmn-connector::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--ftl-blue); transform: translateX(-50%); }
.bpmn-connector::after { content: ''; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--ftl-blue); }

/* ===== STATE MACHINE ===== */
.state-flow { display: flex; align-items: center; gap: 0; flex-wrap: wrap; justify-content: center; margin: 20px 0 32px; }
.state-node { padding: 8px 16px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; letter-spacing: .3px; border: 2px solid transparent; }
.state-node.collecting { background: #E2E8F0; color: #475569; border-color: #CBD5E1; }
.state-node.active-state { background: #DBEAFE; color: #1E40AF; border-color: #93C5FD; }
.state-node.certified { background: #D1FAE5; color: #065F46; border-color: #6EE7B7; box-shadow: 0 0 0 3px rgba(110,231,183,.2); }
.state-arrow { padding: 0 6px; color: var(--ftl-blue); font-size: 16px; font-weight: 700; }

/* ===== ARCH DIAGRAM ===== */
.arch { display: grid; grid-template-rows: auto auto auto; gap: 24px; margin: 24px 0; }
.arch-tier { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.arch-tier-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); text-align: center; margin-bottom: 8px; font-weight: 600; }
.arch-box { background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; text-align: center; font-size: 12px; box-shadow: var(--shadow); min-width: 120px; }
.arch-box strong { display: block; font-size: 13px; color: var(--ftl-blue); }
.arch-box small { color: var(--text-secondary); font-size: 10px; }
.arch-box.primary { border: 2px solid var(--ftl-blue); }
.arch-connector { height: 28px; position: relative; font-size: 0; color: transparent; }
.arch-connector::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--ftl-blue); opacity: .3; transform: translateX(-50%); }
.arch-connector::after { content: ''; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--ftl-blue); opacity: .4; }

/* ===== LCS FLOW ===== */
.lcs-flow { display: flex; align-items: center; gap: 0; flex-wrap: wrap; justify-content: center; margin: 20px 0; }
.lcs-node { padding: 12px 18px; border-radius: var(--radius); font-size: 12px; text-align: center; min-width: 120px; border: 1px solid var(--border); border-top: 3px solid var(--ftl-blue); background: var(--bg-white); box-shadow: var(--shadow); }
.lcs-node strong { display: block; font-size: 12px; font-weight: 700; color: var(--ftl-blue); margin-bottom: 2px; }
.lcs-node small { color: var(--text-secondary); font-size: 10px; }
.lcs-arrow { padding: 0 6px; color: var(--ftl-blue); font-size: 18px; font-weight: 700; }

/* ===== RESPONSIVE ===== */

/* --- Tablet: 768px - 1024px --- */
@media (max-width: 1024px) {
  .main { padding: 24px 20px 40px; }
  .page-title { font-size: 24px; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .card-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .arch-box { min-width: 100px; padding: 8px 12px; }
  .arch-box strong { font-size: 12px; }
  .bpmn-node { min-width: 110px; padding: 10px 10px; }
  .bpmn-name { font-size: 11px; }
  .bpmn-arrow { width: 28px; }
  .bpmn-arrow::before { width: 18px; }
  .lcs-node { min-width: 100px; padding: 8px 12px; font-size: 11px; }
}

/* --- Mobile: < 768px --- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; -webkit-tap-highlight-color: transparent; }
  .sidebar-backdrop.visible { display: block; }
  .hamburger { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; top: 8px; left: 8px; }
  .main { margin-left: 0; padding: 60px 16px 40px; }
  .page-title { font-size: 22px; }
  .page-subtitle { font-size: 13px; margin-bottom: 20px; }
  .cp-name { font-size: 20px; }
  .cp-num { width: 48px; height: 48px; font-size: 18px; box-shadow: 0 1px 4px rgba(14,79,95,.2); }
  .cp-header { gap: 12px; padding: 16px; border-left-width: 3px; }
  .section-heading { font-size: 16px; margin: 24px 0 12px; }
  .nav-link { padding: 12px 20px 12px 24px; font-size: 14px; min-height: 44px; display: flex; align-items: center; }
  .nav-link.sub { padding-left: 36px; font-size: 13px; }
  .nav-group-label { padding: 14px 20px 8px; font-size: 11px; min-height: 40px; display: flex; align-items: center; }
  .card { padding: 16px; margin-bottom: 16px; }
  .card h3 { font-size: 15px; }
  .card-grid { grid-template-columns: 1fr; gap: 16px; }
  .card-grid-3 { grid-template-columns: 1fr; gap: 12px; }
  .card:hover { transform: none; box-shadow: var(--shadow); }
  table { font-size: 12px; }
  table th { padding: 8px 10px; font-size: 10px; }
  .campos-table td:first-child { font-size: 11px; }
  table td { padding: 8px 10px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
  .bpmn-row { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 8px 0 12px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scroll-snap-type: x proximity; }
  .bpmn-node { min-width: 110px; padding: 10px 10px; scroll-snap-align: start; }
  .bpmn-name { font-size: 11px; }
  .bpmn-node .badge { font-size: 8px; padding: 2px 5px; }
  .bpmn-arrow { width: 24px; }
  .bpmn-arrow::before { width: 16px; }
  .bpmn-node:hover { transform: none; }
  .state-flow { flex-direction: column; gap: 0; align-items: stretch; }
  .state-node { text-align: center; }
  .state-arrow { transform: rotate(90deg); padding: 2px 0; text-align: center; }
  .arch-tier { gap: 8px; }
  .arch-box { min-width: 90px; padding: 8px 10px; font-size: 11px; }
  .arch-box strong { font-size: 12px; }
  .arch-box small { font-size: 9px; }
  .lcs-flow { flex-direction: column; gap: 0; align-items: stretch; }
  .lcs-node { min-width: auto; }
  .lcs-arrow { transform: rotate(90deg); padding: 2px 0; text-align: center; }
  .epcis-card { grid-template-columns: 1fr; }
  .endpoint-card { font-size: 12px; padding: 12px 14px; overflow-x: auto; word-break: break-all; }
  .cp-pipeline { padding: 10px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cp-pip-dot { width: 24px; height: 24px; font-size: 9px; }
  .cp-pip-line { width: 8px; }
  .cp-pip-label { display: none; }
  .callout { font-size: 12px; padding: 12px 14px; }
}

/* --- Small mobile: < 480px --- */
@media (max-width: 480px) {
  .main { padding: 56px 12px 32px; }
  .page-title { font-size: 20px; }
  .cp-name { font-size: 18px; }
  .cp-num { width: 42px; height: 42px; font-size: 16px; }
  .cp-header { padding: 12px; }
  .bpmn-node { min-width: 95px; padding: 8px 8px; }
  .bpmn-cp { font-size: 10px; }
  .bpmn-name { font-size: 10px; margin: 2px 0; }
  .bpmn-arrow { width: 18px; }
  .bpmn-arrow::before { width: 12px; }
  .bpmn-arrow::after { border-width: 4px; }
  .cp-pipeline { padding: 8px 10px; }
  .cp-pip-dot { width: 22px; height: 22px; font-size: 8px; }
  .cp-pip-line { width: 6px; }
  .arch-tier { flex-direction: column; align-items: center; }
  .arch-box { width: 100%; max-width: 200px; }
}

/* --- Landscape mobile --- */
@media (max-height: 500px) and (orientation: landscape) {
  .hamburger { top: 0; left: 0; width: 44px; height: 44px; font-size: 18px; }
  .main { padding-top: 44px; }
  .sidebar-brand { padding: 16px 16px; }
  .sidebar-brand h1 { font-size: 18px; }
  .nav-link { padding-top: 8px; padding-bottom: 8px; min-height: 36px; font-size: 13px; }
}

/* ===== PRINT ===== */
@media print {
  .sidebar, .hamburger, .sidebar-backdrop { display: none !important; }
  .main { margin-left: 0; padding: 20px; max-width: 100%; }
  .page-section { display: block !important; page-break-before: always; animation: none !important; }
  .page-section:first-child { page-break-before: auto; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  .card:hover { transform: none; box-shadow: none; }
  .cp-pipeline { box-shadow: none; border: 1px solid #ccc; }
  .cp-pip-dot { border-color: #999; }
  .cp-pip.done .cp-pip-dot { background: #666; border-color: #666; }
  .cp-pip.current .cp-pip-dot { background: #333; border-color: #333; box-shadow: none; }
  table { page-break-inside: avoid; }
  .bpmn { page-break-inside: avoid; }
  .bpmn-node { box-shadow: none; border-width: 1px; }
  .bpmn-node:hover { transform: none; }
  .arch-box { box-shadow: none; }
  .cp-header { box-shadow: none; border-left-color: #333; }
  .cp-num { box-shadow: none; }
  .lcs-node { box-shadow: none; border-top-color: #333; }
  .state-node { border-color: #ccc; }
  .state-node.certified { box-shadow: none; }
  a[href]::after { content: ' (' attr(href) ')'; font-size: 10px; color: #666; }
  body { font-size: 11px; color: #000; }
  .state-flow { flex-wrap: nowrap; }
}
