:root {
  --primary:       #7c3aed;
  --primary-dark:  #6d28d9;
  --primary-light: #f5f3ff;
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #0f172a;
  --text-muted:    #64748b;
  --sidebar-bg:    #152d07;
  --sidebar-text:  #8fbb6a;
  --sidebar-active:#ffffff;
  --sidebar-w:     220px;
  --radius:        8px;
  --shadow:        0 1px 3px rgba(0,0,0,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 6px;
  margin: 2px 8px;
  transition: background .15s, color .15s;
}

.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.12); color: var(--sidebar-active); }
.nav-logout { color: #f87171; }
.nav-logout:hover { background: rgba(248,113,113,.15); color: #f87171; }
.sidebar-spacer { flex: 1; }
.sidebar-section { padding: 12px 16px 4px; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.35); }
.nav-external { opacity: .85; }
.nav-external::after { content: '↗'; font-size: 10px; margin-left: auto; opacity: .5; }
.sidebar-footer { padding: 12px 16px; font-size: 10px; color: rgba(255,255,255,.3); line-height: 1.4; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  max-width: 1200px;
}

.main-auth {
  margin-left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
}

.page-actions { display: flex; gap: 8px; align-items: center; }

.breadcrumb-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  display: block;
  margin-bottom: 4px;
}
.breadcrumb-link:hover { color: var(--primary); }

.crumb-link { color: var(--primary); text-decoration: none; }
.crumb-link:hover { text-decoration: underline; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 20px; }
.card-body.p0 { padding: 0; }
.mb { margin-bottom: 20px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.table-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.table-link:hover { text-decoration: underline; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.mono { font-family: 'Cascadia Code', 'Fira Code', monospace; font-size: 13px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
}
.badge-type   { border-radius: 4px; font-size: 11px; padding: 2px 6px; }
.badge-static { background: #f0fdf4; color: #166534; }
.badge-php    { background: #eff6ff; color: #1e40af; }
.badge-db     { background: #fef3c7; color: #92400e; font-family: monospace; }
.badge-ssl    { background: #dcfce7; color: #166534; }
.badge-danger    { background: #fef2f2; color: #991b1b; }
.badge-wordpress { background: #e6f2fa; color: #00669b; }
.badge-nextjs    { background: #f1f5f9; color: #0f172a; }
.badge-joomla    { background: #fff4e6; color: #b45309; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost    { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger-ghost { color: #ef4444; }
.btn-danger-ghost:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-muted); padding: 2px 6px; border-radius: 4px; }
.btn-close:hover { background: var(--bg); color: var(--text); }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.auth-wrap { width: 100%; max-width: 380px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.auth-logo { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; margin-bottom: 28px; }

.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 560px; box-shadow: 0 20px 40px rgba(0,0,0,.15); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--border); }

.meta-row { display: flex; gap: 32px; flex-wrap: wrap; }
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 600; }
.meta-value { font-size: 14px; display: flex; align-items: center; gap: 8px; }

.flash { padding: 10px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; font-weight: 500; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* File editor */
.editor-area {
  font-family: 'Cascadia Code', 'Fira Code', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  min-height: 600px;
  resize: vertical;
  border: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px 20px;
  tab-size: 2;
}
.editor-area:focus { outline: none; }

/* DB info */
.input-reveal { display: flex; gap: 8px; align-items: center; }
.input-reveal .form-control { flex: 1; }

/* Tabs */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab-btn { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); cursor: pointer; font-size: 13px; font-weight: 500; padding: 8px 16px; margin-bottom: -1px; transition: color .15s, border-color .15s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { border-bottom-color: var(--green, #3fb950); color: var(--text); }

/* ── Dark mode ───────────────────────────────────────────────────────────── */
html.dark {
  --bg:          #0d1117;
  --surface:     #161b22;
  --border:      #30363d;
  --text:        #c9d1d9;
  --text-muted:  #8b949e;
  --primary-light: #1e1535;
  --shadow:      0 1px 3px rgba(0,0,0,.4);
}
html.dark body { background: var(--bg); color: var(--text); }
html.dark .table th { background: var(--surface); color: var(--text-muted); }
html.dark .table tbody tr:hover { background: rgba(255,255,255,.04); }
html.dark .btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
html.dark .btn-secondary:hover { background: #1f262e; }
html.dark .btn-ghost:hover { background: rgba(255,255,255,.06); color: var(--text); }
html.dark .btn-danger-ghost:hover { background: rgba(239,68,68,.12); }
html.dark .btn-close:hover { background: rgba(255,255,255,.08); }
html.dark .form-control { background: #0d1117; border-color: var(--border); color: var(--text); }
html.dark .auth-card { background: var(--surface); }
html.dark .flash-success { background: #0d2318; color: #4ade80; border-color: #166534; }
html.dark .flash-error   { background: #2d0d0d; color: #f87171; border-color: #7f1d1d; }
html.dark .flash-info    { background: #0d1a2d; color: #60a5fa; border-color: #1e3a5f; }
html.dark .badge-static  { background: #0d2318; color: #4ade80; }
html.dark .badge-php     { background: #0d1a2d; color: #60a5fa; }
html.dark .badge-db      { background: #2a1f0d; color: #fbbf24; }
html.dark .badge-ssl     { background: #0d2318; color: #4ade80; }
html.dark .badge-danger     { background: #2d0d0d; color: #f87171; }
html.dark .badge-wordpress { background: #0d1a2d; color: #7dd3fc; }
html.dark .badge-nextjs    { background: #1e293b; color: #cbd5e1; }
html.dark .badge-joomla    { background: #2a1a00; color: #fbbf24; }

/* Dark mode toggle button */
.btn-dark-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  transition: background .15s, color .15s;
}
.btn-dark-toggle:hover { background: var(--bg); color: var(--text); }

/* ── As Built content area ───────────────────────────────────────────────── */
.ab-content {
  line-height: 1.75;
  color: var(--text);
  max-width: 900px;
}
.ab-content h1, .ab-content h2, .ab-content h3, .ab-content h4 {
  font-weight: 600;
  margin: 1.6em 0 0.5em;
  line-height: 1.3;
  color: var(--text);
}
.ab-content h1 { font-size: 1.5em; }
.ab-content h2 { font-size: 1.25em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.ab-content h3 { font-size: 1.1em; }
.ab-content h4 { font-size: 1em; }
.ab-content p  { margin: 0.75em 0; }
.ab-content ul, .ab-content ol { margin: 0.75em 0; padding-left: 1.75em; }
.ab-content li { margin: 0.3em 0; }
.ab-content a  { color: var(--primary); text-decoration: none; }
.ab-content a:hover { text-decoration: underline; }
.ab-content hr { border: none; border-top: 1px solid var(--border); margin: 1.75em 0; }
.ab-content blockquote {
  border-left: 3px solid var(--primary);
  margin: 1em 0;
  padding: 10px 18px;
  background: var(--surface);
  border-radius: 0 6px 6px 0;
  color: var(--text-muted);
}
/* Inline code */
.ab-content code {
  background: #e8edf2;
  color: #1a3a50;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: 'Cascadia Code', 'Fira Code', 'Courier New', monospace;
  font-size: 12.5px;
  font-weight: 400;
}
html.dark .ab-content code {
  background: #1e2433;
  color: #a8d8f0;
}
/* Block code */
.ab-content pre {
  background: #e8edf2;
  border: 1px solid #c8d4de;
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  line-height: 1.65;
  margin: 1em 0;
}
html.dark .ab-content pre {
  background: #1e2433;
  border-color: #2d3a50;
}
.ab-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: #1a3a50;
  font-size: 13px;
}
html.dark .ab-content pre code {
  color: #cdd6f4;
}
/* Tables in content */
.ab-content table { width: 100%; border-collapse: collapse; margin: 1em 0; }
.ab-content th, .ab-content td { border: 1px solid var(--border); padding: 8px 14px; text-align: left; }
.ab-content th { background: var(--surface); font-weight: 600; font-size: 13px; }
.ab-content tbody tr:hover { background: rgba(0,0,0,.03); }
html.dark .ab-content tbody tr:hover { background: rgba(255,255,255,.04); }

/* ── As Built component classes (used in DB-stored HTML content) ─────────── */
.ab-toc { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:28px; padding:16px; background:var(--card-bg); border:1px solid var(--border); border-radius:8px; }
.ab-toc a { font-size:13px; color:var(--accent); text-decoration:none; padding:4px 10px; border:1px solid var(--border); border-radius:4px; white-space:nowrap; }
.ab-toc a:hover { background:var(--accent); color:#000; }
.ab-section { margin-bottom:32px; scroll-margin-top:24px; }
.ab-section h2 { font-size:16px; font-weight:700; color:var(--text); margin-bottom:16px; padding-bottom:8px; border-bottom:1px solid var(--border); }
.ab-section h3 { font-size:13px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:.05em; margin:16px 0 8px; }
.ab-table { width:100%; border-collapse:collapse; font-size:13px; margin-bottom:12px; }
.ab-table th { text-align:left; padding:8px 12px; font-size:11px; color:var(--text-muted); text-transform:uppercase; letter-spacing:.06em; border-bottom:1px solid var(--border); }
.ab-table td { padding:9px 12px; border-bottom:1px solid var(--border); color:var(--text-muted); vertical-align:top; }
.ab-table td:first-child { color:var(--text); font-weight:500; white-space:nowrap; }
.ab-table tr:last-child td { border-bottom:none; }
.ab-module-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); gap:10px; margin-bottom:12px; }
.ab-module { background:var(--card-bg); border:1px solid var(--border); border-radius:6px; padding:12px 14px; }
.ab-module-name { font-size:13px; font-weight:600; color:var(--text); margin-bottom:4px; }
.ab-module-desc { font-size:12px; color:var(--text-muted); line-height:1.5; }
/* Code spans and blocks — light bg in light mode, dark in dark mode */
.ab-code { font-family:monospace; font-size:12px; background:#e8edf2; color:#1a3a50; padding:2px 6px; border-radius:4px; }
.ab-block { font-family:monospace; font-size:12px; background:#e8edf2; color:#1a3a50; padding:12px 16px; border-radius:6px; margin-bottom:12px; line-height:1.8; white-space:pre; overflow-x:auto; }
html.dark .ab-code  { background:#111; color:var(--accent); }
html.dark .ab-block { background:#111; color:var(--accent); }
/* Callout boxes */
.ab-note { background:#fffbeb; border:1px solid #F59E0B60; border-radius:6px; padding:10px 14px; font-size:13px; color:#92400e; margin-bottom:12px; }
.ab-tip  { background:#f0fdf4; border:1px solid #10B98160; border-radius:6px; padding:10px 14px; font-size:13px; color:#065f46; margin-bottom:12px; }
html.dark .ab-note  { background:#1a1200; border-color:#F59E0B40; color:#F59E0B; }
html.dark .ab-tip   { background:#0a1a0a; border-color:#10B98140; color:#10B981; }
