:root {
  --primary: #1a56a0;
  --primary-dark: #0f3d7a;
  --primary-light: #e8f0fb;
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-width: 260px;
  --topbar-height: 56px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Sarabun', 'Noto Sans Thai', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 15px;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }

/* ─── Layout ─── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.main-wrap {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-content { padding: 28px 32px; flex: 1; max-width: 1100px; }

/* ─── Sidebar ─── */
.sidebar-logo {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-100);
}
.sidebar-logo .org { font-size: 11px; font-weight: 700; color: var(--gray-400); letter-spacing: 0.08em; text-transform: uppercase; }
.sidebar-logo .project { font-size: 14px; font-weight: 600; color: var(--primary); margin-top: 4px; line-height: 1.3; }
.sidebar-logo .version { display: inline-block; margin-top: 6px; font-size: 10px; background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 10px; font-weight: 600; }

.sidebar-search { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); }
.search-box { position: relative; }
.search-box input {
  width: 100%; background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 7px 10px 7px 32px;
  font-size: 13px; color: var(--gray-700); font-family: inherit;
}
.search-box input:focus { outline: none; border-color: var(--primary); background: #fff; }
.search-box svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--gray-400); width:15px; height:15px; }

.nav-section { padding: 6px 0; }
.nav-label { font-size: 10px; font-weight: 700; color: var(--gray-400); letter-spacing: 0.09em; text-transform: uppercase; padding: 10px 20px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 20px; font-size: 13px; color: var(--gray-600);
  cursor: pointer; border-left: 2px solid transparent;
  transition: all 0.12s;
}
.nav-item:hover { background: var(--gray-50); color: var(--gray-900); }
.nav-item.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .badge { margin-left: auto; font-size: 10px; background: var(--gray-100); color: var(--gray-500); padding: 1px 7px; border-radius: 10px; }
.nav-item .badge.new { background: var(--accent-light); color: #92400e; }

.sidebar-footer { margin-top: auto; padding: 12px 20px; border-top: 1px solid var(--gray-100); font-size: 11px; color: var(--gray-400); display: flex; justify-content: space-between; }

/* ─── Topbar ─── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-400); }
.breadcrumb .sep { font-size: 10px; }
.breadcrumb .current { color: var(--gray-700); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius); font-size: 13px;
  font-family: inherit; cursor: pointer; border: 1px solid var(--gray-200);
  background: #fff; color: var(--gray-600); transition: all 0.12s;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-300); color: var(--gray-800); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn svg { width: 14px; height: 14px; }

/* ─── Cards ─── */
.card { background: #fff; border-radius: 12px; border: 1px solid var(--gray-200); box-shadow: var(--shadow); }
.card-body { padding: 20px 24px; }
.card-header { padding: 16px 24px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 600; color: var(--gray-800); }

/* ─── Stat cards ─── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 12px; border: 1px solid var(--gray-200); padding: 16px 20px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--gray-400); font-weight: 600; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.stat-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.amber { background: var(--accent-light); color: #92400e; }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

/* ─── Flow diagram ─── */
.flow-wrap { overflow-x: auto; padding-bottom: 8px; }
.flow-steps { display: flex; align-items: flex-start; gap: 0; min-width: max-content; }
.flow-step { display: flex; flex-direction: column; align-items: center; width: 100px; }
.flow-node {
  width: 80px; text-align: center; padding: 12px 8px;
  border-radius: 10px; border: 1px solid transparent;
}
.flow-num { font-size: 10px; font-weight: 700; color: #fff; background: var(--primary); width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 6px; }
.flow-icon { font-size: 22px; margin-bottom: 4px; }
.flow-name { font-size: 11px; font-weight: 600; line-height: 1.3; }
.flow-desc { font-size: 10px; color: var(--gray-400); margin-top: 3px; line-height: 1.3; }
.flow-arrow { display: flex; align-items: center; padding: 0 2px; margin-top: 30px; color: var(--gray-300); }
.flow-arrow svg { width: 18px; height: 18px; }

.node-blue { background: #eff6ff; border-color: #bfdbfe; }
.node-blue .flow-name { color: #1e40af; }
.node-green { background: #f0fdf4; border-color: #bbf7d0; }
.node-green .flow-name { color: #15803d; }
.node-amber { background: #fffbeb; border-color: #fde68a; }
.node-amber .flow-name { color: #92400e; }
.node-orange { background: #fff7ed; border-color: #fed7aa; }
.node-orange .flow-name { color: #c2410c; }
.node-purple { background: #faf5ff; border-color: #e9d5ff; }
.node-purple .flow-name { color: #7e22ce; }
.node-gray { background: var(--gray-50); border-color: var(--gray-200); }
.node-gray .flow-name { color: var(--gray-700); }

/* ─── Doc/Component grid ─── */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.doc-card {
  background: #fff; border-radius: 12px; border: 1px solid var(--gray-200);
  padding: 18px 20px; cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column;
}
.doc-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.doc-card-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; font-size: 18px; }
.doc-card-title { font-size: 14px; font-weight: 600; color: var(--gray-800); margin-bottom: 6px; }
.doc-card-desc { font-size: 12px; color: var(--gray-500); line-height: 1.5; flex: 1; }
.doc-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--gray-100); }
.doc-card-tag { font-size: 10px; background: var(--gray-100); color: var(--gray-500); padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.doc-card-meta { font-size: 11px; color: var(--gray-400); }

/* ─── Actors list ─── */
.actors-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.actor-card { background: #fff; border-radius: 12px; border: 1px solid var(--gray-200); padding: 16px 18px; }
.actor-role { font-size: 13px; font-weight: 600; color: var(--gray-800); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.actor-role .icon { font-size: 18px; }
.actor-tasks { list-style: none; }
.actor-tasks li { font-size: 12px; color: var(--gray-500); padding: 3px 0; border-bottom: 1px dashed var(--gray-100); }
.actor-tasks li:last-child { border-bottom: none; }
.actor-tasks li::before { content: "•"; color: var(--primary); margin-right: 6px; }

/* ─── Status table ─── */
.status-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.status-table th { background: var(--gray-50); padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--gray-200); }
.status-table td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); vertical-align: middle; }
.status-table tr:last-child td { border-bottom: none; }
.status-table tr:hover td { background: var(--gray-50); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-amber { background: var(--accent-light); color: #92400e; }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }
.badge-red { background: var(--danger-light); color: var(--danger); }

/* ─── Scope box ─── */
.scope-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.scope-box { border-radius: 12px; padding: 18px 20px; }
.scope-box.in { background: var(--success-light); border: 1px solid #86efac; }
.scope-box.out { background: var(--danger-light); border: 1px solid #fca5a5; }
.scope-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.scope-box.in .scope-title { color: var(--success); }
.scope-box.out .scope-title { color: var(--danger); }
.scope-list { list-style: none; }
.scope-list li { font-size: 12px; padding: 4px 0; display: flex; align-items: flex-start; gap: 6px; }
.scope-box.in .scope-list li { color: #166534; }
.scope-box.out .scope-list li { color: #991b1b; }

/* ─── Page header ─── */
.page-header { margin-bottom: 24px; }
.page-eyebrow { font-size: 11px; font-weight: 700; color: var(--primary); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--gray-900); line-height: 1.25; margin-bottom: 8px; }
.page-desc { font-size: 14px; color: var(--gray-500); line-height: 1.6; max-width: 680px; }
.page-meta { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.meta-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--gray-400); }

/* ─── Section ─── */
.section { margin-bottom: 28px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--gray-800); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--gray-100); }

/* ─── Activity feed ─── */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 6px; }
.activity-dot.amber { background: var(--accent); }
.activity-dot.green { background: var(--success); }
.activity-text { font-size: 13px; color: var(--gray-700); }
.activity-time { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ─── Two col ─── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .main-wrap { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .scope-grid { grid-template-columns: 1fr; }
}

/* ─── Utility ─── */
.text-muted { color: var(--gray-400); }
.text-sm { font-size: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.font-bold { font-weight: 700; }
