/* ── RESET & BASE ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --navy: #003366;
  --orange: #ff6600;
  --white: #ffffff;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dde1e8;
  --text: #1a1a2e;
  --muted: #6b7280;
  --sidebar-w: 260px;
  --topbar-h: 52px;
  --blue-l: #dbeafe; --blue-d: #1d4ed8;
  --amb-l: #fef3c7;  --amb-d: #92400e;
  --pur-l: #f3e8ff;  --pur-d: #6b21a8;
  --grn-l: #d1fae5;  --grn-d: #065f46;
  --pnk-l: #fce7f3;  --pnk-d: #9d174d;
  --tel-l: #cffafe;  --tel-d: #0e7490;
  --red:   #ef4444;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', 'Fira Code', monospace;
}
html { font-size: 14px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--orange); }

/* ── TOPBAR ───────────────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--navy); display: flex; align-items: center;
  padding: 0 20px; gap: 16px; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.topbar-logo { font-weight: 700; font-size: 13px; color: #fff; letter-spacing: .02em; }
.topbar-logo span { color: var(--orange); }
.topbar-badge {
  background: var(--orange); color: #fff; font-size: 9px; font-weight: 700;
  padding: 2px 7px; border-radius: 3px; letter-spacing: .08em; text-transform: uppercase;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-right a { color: rgba(255,255,255,.7); font-size: 12px; }
.topbar-right a:hover { color: #fff; }
.gh-btn {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  color: #fff !important; padding: 5px 12px; border-radius: 5px; font-size: 11px; font-weight: 600;
}
.gh-btn:hover { background: rgba(255,255,255,.22) !important; color: #fff !important; }

/* ── SIDEBAR ──────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border); overflow-y: auto;
  padding: 16px 0; z-index: 90;
}
.sidebar-section { margin-bottom: 4px; }
.sidebar-domain {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  cursor: pointer; user-select: none;
}
.sidebar-domain:hover { color: var(--navy); }
.sidebar-domain .chevron { font-size: 9px; transition: transform .2s; }
.sidebar-domain.open .chevron { transform: rotate(90deg); }
.sidebar-l2 { display: none; }
.sidebar-l2.open { display: block; }
.sidebar-l2-link {
  display: block; padding: 6px 16px 6px 28px;
  font-size: 12px; color: var(--muted); font-weight: 500;
}
.sidebar-l2-link:hover { color: var(--navy); background: var(--bg); }
.sidebar-l3 { }
.sidebar-l3-link {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 16px 5px 40px; font-size: 11.5px; color: var(--muted);
}
.sidebar-l3-link:hover { color: var(--navy); background: var(--bg); }
.sidebar-l3-link.active { color: var(--navy); font-weight: 700; background: var(--blue-l); border-right: 3px solid var(--orange); }
.sidebar-l3-link .pid { font-family: var(--mono); font-size: 9px; background: var(--border); padding: 1px 5px; border-radius: 2px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.status-done { background: #10b981; }
.status-queue { background: #f59e0b; }
.status-wip { background: #3b82f6; }

/* ── MAIN CONTENT ─────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w); margin-top: var(--topbar-h);
  padding: 32px 40px; max-width: 1100px;
}

/* ── BREADCRUMB ───────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted); margin-bottom: 20px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--orange); }
.breadcrumb .sep { opacity: .4; }
.breadcrumb .current { color: var(--navy); font-weight: 600; }

/* ── PAGE HEADER ──────────────────────────────────────────────────────── */
.page-header {
  background: linear-gradient(135deg, var(--navy) 0%, #1a4a7a 100%);
  border-radius: 12px; padding: 28px 32px; margin-bottom: 28px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
}
.page-header-left h1 { color: #fff; font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.page-header-left p { color: rgba(255,255,255,.65); font-size: 12px; }
.page-header-meta { display: flex; flex-direction: column; gap: 6px; text-align: right; }
.pid-badge {
  background: var(--orange); color: #fff; font-family: var(--mono);
  font-size: 13px; font-weight: 700; padding: 6px 14px; border-radius: 6px;
}
.status-badge {
  font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .07em;
}
.status-badge.complete { background: var(--grn-l); color: var(--grn-d); }
.status-badge.queued { background: var(--amb-l); color: var(--amb-d); }

/* ── SECTION CARD ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 24px; overflow: hidden;
}
.card-header {
  padding: 14px 20px; background: var(--navy); display: flex; align-items: center; gap: 10px;
}
.card-header h2 { color: #fff; font-size: 13px; font-weight: 600; }
.card-header .icon { font-size: 16px; }
.card-body { padding: 20px; }

/* ── DIAGRAM ──────────────────────────────────────────────────────────── */
.diagram-wrap {
  background: #f8fafc; border-radius: 8px; padding: 16px;
  display: flex; justify-content: center; align-items: center;
  border: 1px solid var(--border);
}
.diagram-wrap img { max-width: 100%; border-radius: 6px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.diagram-placeholder {
  width: 100%; min-height: 200px; background: #f1f5f9;
  border: 2px dashed var(--border); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); font-size: 12px;
}
.diagram-placeholder .ico { font-size: 32px; opacity: .4; }

/* ── L4 TABLE ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
thead tr { background: var(--navy); }
thead th {
  padding: 10px 12px; color: #fff; font-weight: 600; font-size: 10px;
  text-transform: uppercase; letter-spacing: .07em; text-align: left; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: #f8fafc; }
tbody tr.phase-break td:first-child { border-left: 3px solid var(--orange); }
tbody td { padding: 9px 12px; vertical-align: top; line-height: 1.5; }
.td-step { font-family: var(--mono); font-weight: 700; color: var(--navy); font-size: 10px; white-space: nowrap; }
.td-name { font-weight: 600; min-width: 180px; }
.td-role { color: var(--muted); font-size: 10.5px; }
.td-sys { }
.flag { display: inline-block; width: 18px; height: 18px; border-radius: 3px; font-size: 9px; font-weight: 700; text-align: center; line-height: 18px; }
.flag-y { background: #fef3c7; color: #92400e; }
.flag-n { background: #f1f5f9; color: #9ca3af; }

/* system tags */
.stag {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-family: var(--mono); font-size: 9px; margin: 1px; font-weight: 500;
}
.amadeus { background: var(--blue-l); color: var(--blue-d); }
.aws     { background: var(--amb-l);  color: var(--amb-d); }
.custom  { background: var(--pur-l);  color: var(--pur-d); }
.gds     { background: var(--pnk-l);  color: var(--pnk-d); }
.noc     { background: var(--tel-l);  color: var(--tel-d); }

/* ── METADATA GRID ────────────────────────────────────────────────────── */
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media(max-width:800px) { .meta-grid { grid-template-columns: 1fr; } }

.meta-section { margin-bottom: 20px; }
.meta-section h3 {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--navy); border-bottom: 2px solid var(--orange); padding-bottom: 4px; margin-bottom: 10px;
}
.krow {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; padding: 4px 0; border-bottom: 1px solid #f0f0f0; gap: 12px;
}
.kname { color: var(--muted); flex-shrink: 0; }
.kval  { font-weight: 700; color: var(--navy); font-family: var(--mono); font-size: 10px; text-align: right; }

.swim { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 11.5px; }
.dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.risk-card {
  background: #fff5f5; border-left: 3px solid var(--red);
  padding: 8px 12px; border-radius: 4px; font-size: 11px;
  margin-bottom: 7px; line-height: 1.55;
}
.risk-card strong { color: #dc2626; }

/* ── PREV/NEXT NAV ────────────────────────────────────────────────────── */
.pn-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border);
}
.pn-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12px; font-weight: 600; color: var(--navy);
  transition: all .15s;
}
.pn-btn:hover { border-color: var(--orange); color: var(--orange); background: #fff8f0; }
.pn-btn .arrow { font-size: 16px; }
.pn-btn .sub { font-size: 10px; font-weight: 400; color: var(--muted); display: block; }

/* ── INDEX PAGE ───────────────────────────────────────────────────────── */
.domain-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 20px; }
.domain-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; transition: box-shadow .15s, transform .15s;
}
.domain-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.1); transform: translateY(-2px); }
.domain-card-hdr { padding: 16px 18px; background: var(--navy); }
.domain-card-hdr h3 { color: #fff; font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.domain-card-hdr p { color: rgba(255,255,255,.55); font-size: 10px; }
.domain-card-body { padding: 14px 18px; }
.domain-card-stat { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.domain-card-link {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 10px; font-size: 11px; font-weight: 700; color: var(--orange);
}

/* ── SCROLLBAR ────────────────────────────────────────────────────────── */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── SIDEBAR COLLAPSE ──────────────────────────────────────────────────── */

/* ── BPMN LIGHTBOX ─────────────────────────────────────────────────────── */
#bpmn-lightbox {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.9); flex-direction: column;
}
#bpmn-lightbox.lb-open { display: flex; }
#lb-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: #060d1f; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
#lb-title { color: rgba(255,255,255,.6); font-size: 12px; font-weight: 600; letter-spacing:.03em; }
#lb-controls { display: flex; gap: 8px; }
#lb-controls button {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  color: #fff; padding: 5px 14px; border-radius: 5px; cursor: pointer;
  font-size: 14px; font-weight: 700; transition: background .15s;
}
#lb-controls button:hover { background: var(--orange); border-color: var(--orange); }
#lb-canvas {
  flex: 1; overflow: hidden; display: flex; align-items: center;
  justify-content: center; cursor: grab;
}
#lb-img {
  max-width: none; max-height: none; transform-origin: center center;
  user-select: none; pointer-events: none; border-radius: 4px;
  box-shadow: 0 4px 40px rgba(0,0,0,.5);
}
#lb-hint {
  text-align: center; padding: 8px 20px; background: #060d1f;
  color: rgba(255,255,255,.3); font-size: 10px; flex-shrink: 0;
}
.diagram-wrap img { cursor: zoom-in; }

/* ── SEARCH (topbar input → navigates to search.html on Enter) ──────────── */
.search-box {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  color: #fff;
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  padding: 5px 10px;
  transition: all .15s;
  width: 200px;
}
.search-box:focus {
  background: rgba(255,255,255,.18);
  border-color: var(--orange);
  width: 240px;
}
.search-box::placeholder { color: rgba(255,255,255,.4); }
.sr-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 12px; }

/* ═══════════════════════════════════════════════════════════════
   COLLAPSIBLE SIDEBAR — desktop icon-rail + hover expand
   ═══════════════════════════════════════════════════════════════ */

:root {
  --sidebar-w:        260px;
  --sidebar-rail-w:   52px;   /* icon-only collapsed width */
  --sidebar-trans:    .22s ease;
}

/* ── Base sidebar ── */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 90;
  transition: width var(--sidebar-trans);
  padding: 10px 0;
}

/* ── Main content offset ── */
.main {
  margin-left: var(--sidebar-w);
  transition: margin-left var(--sidebar-trans);
}

/* ── L1 domain icon pills (always visible) ── */
.sidebar-domain {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  border-radius: 0;
  transition: background .15s, color .15s;
}
.sidebar-domain:hover { color: var(--navy); background: var(--bg); }
.sidebar-domain .domain-icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--blue-l);
  transition: background .15s;
}
.sidebar-domain:hover .domain-icon,
.sidebar-domain.open .domain-icon { background: var(--navy); filter: brightness(10); }
.sidebar-domain .domain-label { transition: opacity var(--sidebar-trans); }
.sidebar-domain .chevron { margin-left: auto; font-size: 9px; transition: transform .2s; flex-shrink: 0; }
.sidebar-domain.open .chevron { transform: rotate(90deg); }

/* ── Collapsed rail — icon only ── */
.sidebar.rail {
  width: var(--sidebar-rail-w);
}
.sidebar.rail ~ .main {
  margin-left: var(--sidebar-rail-w);
}
.sidebar.rail .sidebar-domain {
  padding: 8px 13px;
  justify-content: center;
}
.sidebar.rail .domain-label,
.sidebar.rail .chevron,
.sidebar.rail .sidebar-l2,
.sidebar.rail .sidebar-l2-link,
.sidebar.rail .sidebar-l3 { 
  opacity: 0;
  pointer-events: none;
  height: 0;
  overflow: hidden;
}
.sidebar.rail .domain-icon {
  background: var(--blue-l);
  filter: none;
}
.sidebar.rail .sidebar-domain:hover .domain-icon {
  background: var(--orange);
  filter: brightness(10);
}

/* Tooltip on hover in rail mode */
.sidebar.rail .sidebar-domain {
  position: relative;
}
.sidebar.rail .sidebar-domain::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-rail-w) + 4px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--navy);
  color: #fff;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 200;
}
.sidebar.rail .sidebar-domain:hover::after { opacity: 1; }

/* ── Toggle button ── */
#sidebarToggle, #sidebar-toggle {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  left: calc(var(--sidebar-w) - 13px);
  z-index: 200;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left var(--sidebar-trans), background .15s;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
#sidebarToggle:hover, #sidebar-toggle:hover { background: var(--navy); color: #fff; }

.sidebar.rail ~ #sidebarToggle,
.sidebar.rail ~ #sidebar-toggle {
  left: calc(var(--sidebar-rail-w) - 13px);
}

/* ── Drag handle ── */
#sidebar-resizer {
  position: fixed;
  top: var(--topbar-h);
  left: var(--sidebar-w);
  width: 4px;
  height: calc(100vh - var(--topbar-h));
  cursor: col-resize;
  z-index: 95;
  background: transparent;
  transition: left var(--sidebar-trans);
}
#sidebar-resizer:hover,
#sidebar-resizer.dragging { background: var(--orange); }
.sidebar.rail ~ #sidebar-resizer {
  left: var(--sidebar-rail-w);
}

/* ── Mobile overlay ── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 85;
  cursor: pointer;
}
#sidebar-overlay.active { display: block; }

/* ── Mobile ── */
@media (max-width: 900px) {
  .sidebar {
    width: var(--sidebar-w) !important;
    transform: translateX(calc(-1 * var(--sidebar-w)));
    transition: transform var(--sidebar-trans);
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
  }
  .main { margin-left: 0 !important; }
  #sidebarToggle, #sidebar-toggle { left: 8px !important; }
  #sidebar-resizer { display: none; }
  .sidebar.rail .domain-label,
  .sidebar.rail .chevron,
  .sidebar.rail .sidebar-l2 {
    opacity: 1; pointer-events: auto; height: auto; overflow: visible;
  }
  .topbar-right a:not(.gh-btn) { display: none; }
  .search-box { width: 140px; }
}

@media (max-width: 480px) {
  :root { --sidebar-w: 240px; }
  .search-box { width: 100px; }
}
