:root {
  --bg: #eef2f7;
  --panel: #fff;
  --panel-soft: #f8fafc;
  --border: #dbe3ef;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --internal: #dbeafe;
  --external: #fef3c7;
  --tabular: #dcfce7;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

.demo-badge {
  position: fixed; top: 10px; left: 10px; z-index: 200;
  padding: 5px 10px; border-radius: 8px; background: #0f172a; color: #f8fafc;
  font-size: 11px; font-weight: 600;
}

.demo-back {
  position: fixed; top: 10px; right: 10px; z-index: 200;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); text-decoration: none; font-size: 12px;
  box-shadow: var(--shadow);
}

.toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 16px; border-radius: 8px; background: #0f172a; color: #fff;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 300;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.shell { display: grid; grid-template-rows: 48px 1fr; min-height: 100vh; }

.shell-header {
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  border-bottom: 1px solid var(--border); background: var(--panel);
}

.shell-header h1 { margin: 0; font-size: 16px; }
.shell-header span { font-size: 12px; color: var(--muted); }

.shell-body { display: grid; grid-template-columns: 180px 1fr; min-height: 0; }

.sidebar {
  border-right: 1px solid var(--border); background: var(--panel-soft);
  padding: 12px; display: flex; flex-direction: column; gap: 4px;
}

.sidebar-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
}

.sidebar-item {
  padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--muted);
}

.sidebar-item.active { background: var(--accent-soft); color: #1e40af; font-weight: 600; }

.workspace {
  padding: 20px 24px 32px; overflow: auto;
  display: flex; justify-content: center; align-items: flex-start;
}

.mem-stage {
  width: 100%; max-width: 720px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); padding: 20px 22px 24px;
  box-shadow: var(--shadow);
}

.mem-context {
  font-size: 11px; color: var(--muted); margin-bottom: 14px;
  padding-bottom: 10px; border-bottom: 1px dashed var(--border);
}

.mem-block-title {
  margin: 0 0 14px; font-size: 13px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}

/* —— Classic cards (CMS baseline) —— */
.mem-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}

.mem-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc;
}

.mem-card-head { display: flex; gap: 10px; align-items: flex-start; }
.mem-icon { font-size: 20px; line-height: 1; }
.mem-card strong { display: block; font-size: 14px; }
.mem-path { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
.mem-stat { margin: 0; font-size: 12px; font-weight: 600; color: #475569; }
.mem-excerpt { margin: 0; font-size: 12px; line-height: 1.45; color: var(--muted); }
.mem-recent { margin: 0; padding-left: 16px; font-size: 12px; color: var(--muted); }

.mem-open {
  align-self: flex-start; margin-top: auto;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); font-size: 12px; font-weight: 600; cursor: pointer;
}

.mem-open:hover { background: var(--accent-soft); border-color: #93c5fd; }

/* —— Row / compact —— */
.mem-list { display: flex; flex-direction: column; gap: 8px; }

.mem-row {
  display: grid; grid-template-columns: 36px 1fr auto 20px; gap: 12px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); cursor: pointer; text-align: left;
}

.mem-row:hover { border-color: #93c5fd; background: var(--accent-soft); }
.mem-row-icon { font-size: 22px; text-align: center; }
.mem-row-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mem-row-body strong { font-size: 14px; }
.mem-row-stat { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.mem-chevron { font-size: 18px; color: var(--muted); }
.mem-recent-inline { font-size: 11px; color: var(--muted); }

.mem-tabs, .mem-segment {
  display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap;
}

.mem-tabs button, .mem-segment button {
  border: 1px solid var(--border); background: var(--panel-soft);
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  color: var(--muted); cursor: pointer;
}

.mem-tabs button.active, .mem-segment button.active {
  background: var(--accent-soft); border-color: #93c5fd; color: #1e40af;
}

.mem-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mem-table th, .mem-table td { border: 1px solid var(--border); padding: 10px 12px; text-align: left; }
.mem-table th { background: var(--panel-soft); font-weight: 600; width: 120px; }
.mem-table tr { cursor: pointer; }
.mem-table tr:hover td { background: var(--accent-soft); }

.mem-chip-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.mem-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel-soft); font-size: 13px; cursor: pointer;
}
.mem-chip:hover { background: var(--accent-soft); }
.mem-chip-badge {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--accent-soft); color: #1e40af;
}

.mem-kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mem-kpi {
  text-align: center; padding: 16px 10px; border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer;
}
.mem-kpi:hover { border-color: #93c5fd; }
.mem-kpi-val { font-size: 22px; font-weight: 700; display: block; }
.mem-kpi-label { font-size: 11px; color: var(--muted); margin-top: 4px; display: block; }

.mem-tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mem-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px 12px; border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; text-align: center;
}
.mem-tile-icon { font-size: 32px; }
.mem-tile:hover { background: var(--accent-soft); }

details.mem-acc {
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
}
details.mem-acc summary {
  padding: 10px 12px; font-weight: 600; font-size: 13px; cursor: pointer; list-style: none;
}
details.mem-acc summary::-webkit-details-marker { display: none; }
details.mem-acc .mem-acc-body { padding: 0 12px 12px; font-size: 12px; color: var(--muted); }

.mem-progress { height: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin-top: 6px; }
.mem-progress span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

.mem-timeline { border-left: 2px solid var(--border); padding-left: 16px; display: flex; flex-direction: column; gap: 16px; }
.mem-tl-item { position: relative; }
.mem-tl-item::before {
  content: ""; position: absolute; left: -21px; top: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}

.mem-tree { font-size: 12px; padding-left: 8px; }
.mem-tree ul { margin: 4px 0 0; padding-left: 16px; color: var(--muted); }

@media (max-width: 640px) {
  .shell-body { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mem-kpi-grid, .mem-tile-grid { grid-template-columns: 1fr; }
}
