/* ─── Reset & Variables ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 220px;
  --blue: #3b5fe2;
  --blue-light: #eef1fd;
  --blue-tint: #f4f6fc;
  --bg: #f4f6fc;
  --surface: #ffffff;
  --surface2: #f8f9ff;
  --border: #e4e8f5;
  --text: #0d1117;
  --muted: #6b7280;
  --muted2: #9ca3af;
  --green: #16a34a; --green-bg: #f0fdf4; --green-border: #bbf7d0;
  --orange: #ea580c; --orange-bg: #fff7ed; --orange-border: #fed7aa;
  --purple: #7c3aed; --purple-bg: #faf5ff; --purple-border: #e9d5ff;
  --red: #dc2626; --red-bg: #fef2f2; --red-border: #fecaca;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 400;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 1; opacity: 0.5;
}

/* ─── Layout ─────────────────────────────────────────────── */
aside {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 0;
  overflow-y: auto;
  z-index: 100;
}

main {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  min-height: 100vh;
  padding: 40px 48px;
  position: relative; z-index: 2;
}

.content {
  max-width: 1100px;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar-logo {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.sidebar-logo-name { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -0.3px; }
.sidebar-logo-name span { color: var(--blue); }
.sidebar-logo-tag { font-size: 10px; color: var(--muted2); font-family: 'DM Mono', monospace; margin-top: 2px; }

.sidebar-section { padding: 0 12px; margin-bottom: 6px; }
.sidebar-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--muted2); padding: 0 8px; margin-bottom: 3px;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: 7px;
  font-size: 13px; color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--blue-tint); color: var(--text); }
.nav-item.active { background: var(--blue-light); color: var(--blue); font-weight: 500; }
.nav-item-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
}
.sidebar-footer a {
  font-size: 12px; color: var(--muted2); text-decoration: none;
  display: flex; align-items: center; gap: 6px;
  transition: color 0.15s;
}
.sidebar-footer a:hover { color: var(--text); }

/* ─── Page header ────────────────────────────────────────── */
.page-header { margin-bottom: 32px; }
.page-header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.6px; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--muted); }

/* ─── Section ────────────────────────────────────────────── */
.content-section { margin-bottom: 40px; }

.section-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--muted2); margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 500;
  padding: 3px 9px; border-radius: 100px;
  width: fit-content;
}
.badge-blue   { background: var(--blue-light); color: var(--blue);   border: 1px solid #d0d9f8; }
.badge-green  { background: var(--green-bg);   color: var(--green);  border: 1px solid var(--green-border); }
.badge-orange { background: var(--orange-bg);  color: var(--orange); border: 1px solid var(--orange-border); }
.badge-purple { background: var(--purple-bg);  color: var(--purple); border: 1px solid var(--purple-border); }
.badge-red    { background: var(--red-bg);     color: var(--red);    border: 1px solid var(--red-border); }

/* ─── Cards ──────────────────────────────────────────────── */
.card-grid   { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card-grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px;
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.card:hover {
  border-color: #c8d0f0;
  box-shadow: 0 4px 20px rgba(59,95,226,0.07);
  transform: translateY(-1px);
}
.card-icon { font-size: 18px; margin-bottom: 4px; }
.card-name { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: -0.2px; }
.card-desc { font-size: 11px; color: var(--muted2); line-height: 1.4; }

/* ─── File / Note list ───────────────────────────────────── */
.file-list { display: flex; flex-direction: column; gap: 8px; }

.file-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 13px 18px;
  display: flex; justify-content: space-between; align-items: center;
  text-decoration: none; color: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.file-item:hover { border-color: #c8d0f0; background: var(--surface2); }
.file-item-left { display: flex; align-items: center; gap: 12px; }
.file-item-icon { font-size: 15px; flex-shrink: 0; }
.file-item-name { font-size: 13px; font-weight: 500; color: var(--text); }
.file-item-desc { font-size: 11px; color: var(--muted2); margin-top: 1px; }
.file-item-arrow { font-size: 12px; color: var(--muted2); flex-shrink: 0; }

/* ─── Quick links ────────────────────────────────────────── */
.quick-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.quick-link {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 14px;
  font-size: 12px; font-weight: 500; color: var(--muted);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.quick-link:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }

/* ─── Date chip ──────────────────────────────────────────── */
.date-chip {
  display: inline-block;
  font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted2);
  background: var(--surface); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 100px;
  margin-bottom: 32px;
}

/* ─── Skills grid ────────────────────────────────────────── */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.skill-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px;
  display: flex; align-items: flex-start; gap: 12px;
}
.skill-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.skill-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.skill-when { font-size: 11px; color: var(--muted2); line-height: 1.45; }

/* ─── Context cards ──────────────────────────────────────── */
.context-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.context-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px;
}
.context-card-title {
  font-size: 12px; font-weight: 600; color: var(--text);
  margin-bottom: 8px; display: flex; align-items: center; gap: 8px;
}
.context-files { display: flex; flex-direction: column; gap: 4px; }
.context-file {
  font-family: 'DM Mono', monospace; font-size: 11px;
  color: var(--blue); background: var(--blue-tint);
  padding: 4px 8px; border-radius: 4px;
}

/* ─── Pipeline ───────────────────────────────────────────── */
.pipeline-list { display: flex; flex-direction: column; gap: 8px; }
.pipeline-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 13px 18px;
  display: flex; align-items: center; gap: 14px;
}
.pipeline-num { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted2); width: 20px; flex-shrink: 0; }
.pipeline-text { font-size: 13px; color: var(--text); flex: 1; }

/* ─── Clients grid ───────────────────────────────────────── */
.clients-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.client-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.client-card:hover { border-color: #c8d0f0; box-shadow: 0 4px 16px rgba(59,95,226,0.07); transform: translateY(-1px); }
.client-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.client-meta { font-size: 11px; color: var(--muted2); margin-bottom: 8px; font-family: 'DM Mono', monospace; }

/* ─── Sidebar: collapsible section labels ────────────────── */
.sidebar-section-label {
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  user-select: none;
  transition: color 0.12s;
}
.sidebar-section-label:hover { color: var(--muted); }
.section-caret { font-size: 8px; color: var(--muted2); flex-shrink: 0; }
.sidebar-section-items.collapsed { display: none; }

/* ─── Sidebar: nav item with children (Notion-style) ─────── */
.nav-item-wrap {
  display: flex; align-items: center;
}
.nav-item-wrap .nav-item { flex: 1; }
.nav-toggle {
  background: none; border: none;
  color: var(--muted2); font-size: 9px;
  padding: 5px 6px; margin-right: 2px;
  cursor: pointer; flex-shrink: 0; border-radius: 4px;
  transition: transform 0.15s, color 0.15s, background 0.15s;
}
.nav-toggle:hover { color: var(--text); background: var(--blue-tint); }
.nav-toggle.open { transform: rotate(90deg); }

.nav-children { display: none; padding: 1px 0 3px 28px; }
.nav-children.open { display: block; }

.nav-sub {
  display: flex; align-items: center;
  padding: 5px 8px; border-radius: 6px;
  font-size: 12px; color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-sub:hover { background: var(--blue-tint); color: var(--text); }
.nav-sub.active { color: var(--blue); font-weight: 500; }

/* ─── Hamburger (mobile only) ────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 16px; line-height: 1;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: background 0.15s;
}
.hamburger:hover { background: var(--blue-tint); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 99;
}

/* ─── Page TOC ───────────────────────────────────────────── */
.page-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  padding: 10px 0 20px;
  margin-top: -10px;
}

.toc-item {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 5px 13px;
  border-radius: 100px;
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.toc-item:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.toc-item.active {
  color: var(--blue);
  background: var(--blue-light);
  border-color: #d0d9f8;
}

/* ─── Stats row ──────────────────────────────────────────── */
.stats-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.stat-chip {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-value {
  font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -0.5px;
}
.stat-value.positive { color: var(--green); }
.stat-value.warning  { color: var(--orange); }
.stat-value.danger   { color: var(--red); }
.stat-label {
  font-size: 10px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted2);
}

/* ─── Tool pages ─────────────────────────────────────────── */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted2);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

.tool-body {
  font-size: 13px; color: var(--muted);
  line-height: 1.65; max-width: 680px;
}
.tool-body + .tool-body { margin-top: 10px; }

.flow-row {
  display: flex; align-items: center;
  flex-wrap: wrap; gap: 8px; margin-top: 12px;
}
.flow-node {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px;
  font-size: 12px; font-weight: 500; color: var(--text);
}
.flow-node.blue  { background: var(--blue-light); border-color: #d0d9f8; color: var(--blue); }
.flow-node.green { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.flow-node.orange{ background: var(--orange-bg); border-color: var(--orange-border); color: var(--orange); }
.flow-node.purple{ background: var(--purple-bg); border-color: var(--purple-border); color: var(--purple); }
.flow-arrow { color: var(--muted2); font-size: 14px; }

.step-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.step-item {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 13px 16px;
}
.step-num {
  font-family: 'DM Mono', monospace; font-size: 11px;
  color: var(--muted2); width: 20px; flex-shrink: 0; margin-top: 1px;
}
.step-body-text { font-size: 13px; color: var(--text); font-weight: 500; margin-bottom: 3px; }
.step-body-note { font-size: 11px; color: var(--muted2); line-height: 1.5; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag {
  font-family: 'DM Mono', monospace; font-size: 11px;
  color: var(--muted2); background: var(--surface2);
  border: 1px solid var(--border); padding: 4px 10px; border-radius: 6px;
}

.callout {
  border-radius: 10px; padding: 14px 16px;
  font-size: 12px; line-height: 1.65;
}
.callout-orange { background: var(--orange-bg); border: 1px solid var(--orange-border); color: var(--orange); }
.callout-blue   { background: var(--blue-light); border: 1px solid #d0d9f8; color: var(--blue); }
.callout-green  { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }
.callout-purple { background: var(--purple-bg); border: 1px solid var(--purple-border); color: var(--purple); }

.open-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--blue); color: white; text-decoration: none;
  font-size: 13px; font-weight: 600; padding: 9px 20px;
  border-radius: 8px; margin-top: 4px; transition: background 0.15s;
}
.open-btn:hover { background: #2d4fc8; }

.kv-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.kv-row { display: flex; gap: 12px; font-size: 12px; align-items: baseline; }
.kv-key { color: var(--muted2); font-weight: 500; min-width: 120px; flex-shrink: 0; }
.kv-val { color: var(--text); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .hamburger { display: flex; align-items: center; }

  aside {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 150;
  }
  aside.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }

  main {
    margin-left: 0;
    width: 100%;
    padding: 60px 16px 32px;
  }

  .content { max-width: 100%; }
  .page-title { font-size: 20px; }

  /* Grids → 1 col (2 col for clients) */
  .card-grid, .card-grid-2, .skills-grid, .context-grid {
    grid-template-columns: 1fr;
  }
  .clients-grid { grid-template-columns: 1fr 1fr; }

  /* Client chips → horizontal scroll */
  .client-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    scrollbar-width: none;
  }
  .client-chips::-webkit-scrollbar { display: none; }
  .client-chip { flex-shrink: 0; }

  /* Tabs → horizontal scroll */
  .tabs-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
  }
  .tabs-bar::-webkit-scrollbar { display: none; }
  .tab-btn { flex-shrink: 0; padding: 10px 14px; }

  /* Rufus side panel → stack full-width */
  .rufus-layout { flex-direction: column; }
  .rufus-panel {
    width: 100%;
    margin-left: 0;
    margin-top: 24px;
    border-left: none;
    border-top: 1px solid var(--border);
    position: static;
    max-height: none;
    border-radius: 12px;
  }

  /* Roadmap: timeline on new line */
  .roadmap-row { flex-wrap: wrap; gap: 8px; }
  .roadmap-timeline { width: 100%; padding-left: 34px; }

  /* File tree: slightly larger touch targets */
  .tree { font-size: 13px; }
  .tree-folder { padding: 8px; }
}
