
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; color: #333; display: flex; min-height: 100vh; }

.sidebar { width: 260px; background: #1a1a2e; color: #eee; padding: 20px 0; position: fixed; height: 100vh; overflow-y: auto; flex-shrink: 0; }
.sidebar h2 { padding: 0 20px 15px; font-size: 14px; color: #7f8fa6; text-transform: uppercase; letter-spacing: 1px; }
.sidebar a { display: block; padding: 8px 20px; color: #ddd; text-decoration: none; font-size: 13px; border-left: 3px solid transparent; }
.sidebar a:hover, .sidebar a.active { background: #16213e; color: #fff; border-left-color: #4a9dec; }
.sidebar .nav-group { margin-bottom: 2px; }
.sidebar .nav-toggle { display: block; padding: 8px 20px; color: #ddd; font-size: 13px; cursor: pointer; border-left: 3px solid transparent; user-select: none; }
.sidebar .nav-toggle:hover { background: #16213e; color: #fff; }
.sidebar .nav-toggle::before { content: '\25B6'; font-size: 10px; margin-right: 6px; display: inline-block; transition: transform 0.2s; }
.sidebar .nav-group.open > .nav-toggle::before { transform: rotate(90deg); }
.sidebar .nav-children { display: none; }
.sidebar .nav-group.open > .nav-children { display: block; }
.sidebar .nav-children a { padding-left: 36px; font-size: 12px; color: #aab; }
.sidebar .nav-children a:hover, .sidebar .nav-children a.active { color: #fff; }

.main { margin-left: 260px; padding: 30px; flex: 1; }
.main h1 { font-size: 24px; margin-bottom: 20px; color: #1a1a2e; }

.filter-bar { background: #fff; border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filter-bar input[type="text"] { padding: 6px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; width: 250px; }
.filter-bar select { padding: 6px 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; background: #fff; }
.filter-bar label { font-size: 12px; color: #7f8fa6; text-transform: uppercase; font-weight: 600; }
.filter-bar .filter-group { display: flex; align-items: center; gap: 6px; }
.no-results { padding: 30px; text-align: center; color: #7f8fa6; font-size: 14px; display: none; }

.overview-desc { font-size: 15px; color: #555; line-height: 1.6; margin-bottom: 8px; }
.overview-warning { font-size: 15px; color: #c0392b; font-weight: 600; line-height: 1.6; margin-bottom: 8px; padding: 10px 14px; background: #fde8e8; border-left: 4px solid #e74c3c; border-radius: 0 6px 6px 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 30px; }
.stat-card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); text-decoration: none; color: inherit; display: block; transition: box-shadow 0.2s, transform 0.2s; }
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); transform: translateY(-2px); }
.stat-card .label { font-size: 13px; color: #7f8fa6; text-transform: uppercase; }
.stat-card .value { font-size: 28px; font-weight: 700; color: #1a1a2e; margin-top: 5px; }

.group-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 20px; }
.group-card { background: #fff; border-radius: 8px; padding: 15px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); text-decoration: none; color: inherit; display: block; border-left: 4px solid #4a9dec; transition: box-shadow 0.2s; }
.group-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.15); }
.group-card .group-name { font-size: 14px; font-weight: 600; color: #1a1a2e; }
.group-card .group-count { font-size: 12px; color: #7f8fa6; margin-top: 4px; }
.group-card-cite { border-left-color: #f39c12; }
.group-card-co { border-left-color: #4a9dec; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 15px; margin-bottom: 20px; }
.tile { background: #fff; border-radius: 8px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); border-left: 4px solid #4a9dec; }
.tile:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.tile .tile-title { font-size: 15px; font-weight: 600; color: #1a1a2e; margin-bottom: 8px; word-break: break-word; }
.tile .tile-id { font-size: 12px; color: #7f8fa6; margin-bottom: 6px; }
.tile .tile-desc { font-size: 13px; color: #555; margin-bottom: 10px; max-height: 80px; overflow: hidden; text-overflow: ellipsis; }
.tile .tile-attrs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tile .attr { background: #f0f4f8; padding: 3px 8px; border-radius: 4px; font-size: 12px; color: #555; }
.tile .attr .attr-label { font-weight: 600; color: #333; }
.tile .tile-links { border-top: 1px solid #eee; padding-top: 10px; margin-top: 8px; }
.tile .tile-links .link-section { margin-bottom: 6px; }
.tile .tile-links .link-label { font-size: 11px; color: #7f8fa6; text-transform: uppercase; font-weight: 600; }
.tile .tile-links .link-list { list-style: none; padding: 0; margin: 4px 0 0 0; }
.tile .tile-links .link-list li { padding: 1px 0; }
.tile .tile-links .link-list a { font-size: 13px; color: #4a9dec; text-decoration: none; }
.tile .tile-links .link-list a:hover { text-decoration: underline; }
.tile .tile-links .expand-toggle { font-size: 12px; color: #7f8fa6; cursor: pointer; display: inline-block; margin-top: 4px; }
.tile .tile-links .expand-toggle:hover { color: #4a9dec; }
.tile .tile-links .link-list.collapsed li:nth-child(n+6) { display: none; }
.tile .more-links { font-size: 12px; color: #7f8fa6; }
.tile-ad { border-left-color: #e74c3c; }
.tile-cite { border-left-color: #f39c12; }
.tile-pol { border-left-color: #27ae60; }
.tile-co { border-left-color: #4a9dec; }

.search-box { background: #fff; border-radius: 8px; padding: 16px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.search-box input { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.search-box input:focus { outline: none; border-color: #4a9dec; box-shadow: 0 0 0 2px rgba(74,157,236,0.2); }
.search-hint { font-size: 12px; color: #7f8fa6; margin-top: 8px; }
.search-results { list-style: none; }
.search-results li { background: #fff; border-radius: 8px; padding: 14px 18px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); border-left: 4px solid #4a9dec; }
.search-results li.result-cite { border-left-color: #f39c12; }
.search-results li.result-co { border-left-color: #4a9dec; }
.search-results li.result-pol { border-left-color: #27ae60; }

.source-badges { display: flex; gap: 6px; margin-bottom: 8px; }
.source-badge { padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.source-badge-snow { background: #e3f2fd; color: #1565c0; }
.source-badge-mapping { background: #fff3e0; color: #e65100; }


.tile-doc { border-left-color: #8e44ad; }
.group-card-doc { border-left-color: #8e44ad; }
.tile-doc .tile-title { padding-right: 70px; }
.doc-btn { position: absolute; top: 10px; right: 42px; width: 30px; height: 30px; border-radius: 6px; background: #f0f4f8; border: 1px solid #ddd; cursor: pointer; font-size: 16px; line-height: 30px; text-align: center; opacity: 0.85; transition: all 0.2s; z-index: 2; text-decoration: none; color: #555; }
.doc-btn:hover { opacity: 1; background: #8e44ad; color: #fff; border-color: #8e44ad; }
.missing-ref { font-size: 13px; color: #999; }
.doc-section-link { font-size: 13px; color: #8e44ad; text-decoration: none; cursor: pointer; }
.doc-section-link:hover { text-decoration: underline; }
.tile-proc { border-left-color: #16a085; }
.tile-role { border-left-color: #d35400; }
.tile-artifact { border-left-color: #2c3e50; }
.group-card-proc { border-left-color: #16a085; }
.group-card-role { border-left-color: #d35400; }
.group-card-artifact { border-left-color: #2c3e50; }
.domain-badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600; background: #f0f4f8; color: #555; margin-bottom: 6px; }
.step-list { list-style: none; padding: 0; margin: 6px 0; counter-reset: step; }
.step-list li { padding: 2px 0; font-size: 12px; color: #555; counter-increment: step; }
.step-list li::before { content: counter(step) ". "; font-weight: 600; color: #16a085; }
.mermaid-scroll { overflow-x: auto; border: 1px solid #eee; border-radius: 8px; background: #fafbfc; padding: 12px; margin: 12px 0; }
.mermaid-scroll svg { max-width: none !important; height: auto !important; display: block; }

a.tile-link { text-decoration: none; color: inherit; display: block; }
a.tile-link .tile { cursor: pointer; transition: box-shadow 0.2s, transform 0.1s; }
a.tile-link .tile:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); transform: translateY(-1px); }

.tile { position: relative; }
.diagram-section { background: #fff; border-radius: 8px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 20px; }
.diagram-section h2 { font-size: 18px; color: #1a1a2e; margin-bottom: 16px; }
.diagram-section .mermaid { display: flex; justify-content: center; }

.explore-btn { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 6px; background: #f0f4f8; border: 1px solid #ddd; cursor: pointer; font-size: 16px; line-height: 30px; text-align: center; opacity: 0.85; transition: all 0.2s; z-index: 2; }
.explore-btn:hover { opacity: 1; background: #4a9dec; color: #fff; border-color: #4a9dec; }

#explorer-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; justify-content: center; align-items: flex-start; padding: 30px; overflow-y: auto; }
#explorer-content { background: #fff; border-radius: 12px; width: 100%; max-width: 900px; margin: auto; padding: 30px; position: relative; box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
#explorer-close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 24px; cursor: pointer; color: #999; }
#explorer-close:hover { color: #333; }
#explorer-title { font-size: 14px; color: #7f8fa6; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 20px; }

.explorer-graph-wrap { margin-bottom: 16px; }
.explorer-graph-scroll { overflow-x: auto; overflow-y: auto; max-height: 70vh; border: 1px solid #eee; border-radius: 8px; background: #fafbfc; }
.explorer-graph-scroll svg { display: block; min-width: 100%; }
.graph-node rect { transition: filter 0.15s; }
.graph-node:hover rect { filter: brightness(0.95); }

.explorer-current-link { margin-top: 12px; }
.explorer-detail-link { display: inline-block; border-left: 4px solid #4a9dec; padding: 10px 16px; background: #fafbfc; border-radius: 0 8px 8px 0; text-decoration: none; color: inherit; transition: background 0.2s; }
.explorer-detail-link:hover { background: #f0f8ff; }
.explorer-detail-type { font-size: 11px; text-transform: uppercase; font-weight: 600; }
.explorer-detail-name { font-size: 15px; font-weight: 700; color: #1a1a2e; }
#doc-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; justify-content: center; align-items: flex-start; padding: 20px; overflow-y: auto; }
#doc-modal-content { background: #fff; border-radius: 12px; width: 100%; max-width: 1100px; margin: auto; position: relative; box-shadow: 0 8px 32px rgba(0,0,0,0.3); max-height: 90vh; display: flex; flex-direction: column; }
#doc-close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 24px; cursor: pointer; color: #999; z-index: 2; }
#doc-close:hover { color: #333; }
#doc-modal-layout { display: flex; overflow: hidden; flex: 1; min-height: 0; }
#doc-toc { width: 240px; flex-shrink: 0; overflow-y: auto; border-right: 1px solid #eee; padding: 16px 0; background: #fafbfc; }
#doc-toc .toc-type-label { display: block; padding: 10px 16px 8px; font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; border-bottom: 2px solid #eee; margin-bottom: 8px; }
#doc-toc span[data-target] { display: block; padding: 4px 8px; font-size: 13px; color: #555; cursor: pointer; border-left: 2px solid transparent; }
#doc-toc span[data-target]:hover { color: #1a1a2e; background: #f0f4f8; border-left-color: #8e44ad; }
#doc-modal.stacked { background: rgba(0,0,0,0.3); }
#doc-modal.stacked #doc-modal-content { margin-left: 60px; margin-top: 40px; box-shadow: -8px -8px 0 0 rgba(255,255,255,0.7), 0 12px 40px rgba(0,0,0,0.4); }
#doc-body { flex: 1; overflow-y: auto; padding: 30px 40px; line-height: 1.7; }
#doc-body h1 { font-size: 22px; color: #1a1a2e; margin: 24px 0 12px; border-bottom: 1px solid #eee; padding-bottom: 8px; }
#doc-body h2 { font-size: 18px; color: #1a1a2e; margin: 20px 0 10px; }
#doc-body h3 { font-size: 15px; color: #333; margin: 16px 0 8px; }
#doc-body h4, #doc-body h5, #doc-body h6 { font-size: 14px; color: #555; margin: 12px 0 6px; }
#doc-body p { margin: 8px 0; font-size: 14px; color: #333; }
#doc-body table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
#doc-body td, #doc-body th { border: 1px solid #ddd; padding: 6px 10px; text-align: left; }
#doc-body tr:nth-child(even) { background: #fafafa; }
#doc-body ul, #doc-body ol { margin: 8px 0 8px 20px; font-size: 14px; }
#doc-body li { margin: 4px 0; }
#doc-body strong { font-weight: 600; }

.search-results li a { font-size: 14px; font-weight: 600; color: #1a1a2e; text-decoration: none; }
.search-results li a:hover { color: #4a9dec; }
.search-results .result-group { font-size: 12px; color: #7f8fa6; margin-top: 2px; }
.search-results .result-desc { font-size: 13px; color: #555; margin-top: 4px; max-height: 40px; overflow: hidden; text-overflow: ellipsis; }
.search-count { font-size: 13px; color: #7f8fa6; margin-bottom: 12px; }
