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

:root {
  --bg-dark:     #0f1923;
  --bg-dark2:    #162030;
  --bg-dark3:    #1e2d40;
  --border-dark: #1e2d40;
  --text-muted:  #4a6080;
  --text-dim:    #64748b;
  --text-mid:    #94a3b8;
  --text-light:  #cbd5e1;
  --text-active: #7dd3fc;
  --accent:      #e8703a;
  --accent-dark: #c85a28;
  --white:       #ffffff;
  --body-bg:     #f8fafc;
  --body-text:   #1e293b;
  --sidebar-w:   260px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:   'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--body-text);
  background: var(--body-bg);
}

/* ─── Logo icon ─────────────────────────────────────────────────── */
.logo-icon {
  width: 24px; height: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 5px;
  flex-shrink: 0;
}
.logo-icon.large  { width: 40px; height: 40px; border-radius: 9px; }
.logo-icon.xlarge { width: 56px; height: 56px; border-radius: 12px; }

/* ─── Login page ─────────────────────────────────────────────────── */
.login-page {
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-wrap {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.logo-text {
  color: var(--white);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.logo-text.large { font-size: 28px; }

.login-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-card {
  background: var(--bg-dark2);
  border: 1px solid var(--border-dark);
  border-radius: 12px;
  padding: 28px;
  text-align: left;
}

.login-error {
  background: rgba(220, 50, 50, 0.12);
  border: 1px solid rgba(220, 50, 50, 0.3);
  border-radius: 6px;
  color: #f87171;
  font-size: 13px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  color: var(--text-mid);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.field-input {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border-dark);
  border-radius: 7px;
  color: var(--text-light);
  font-size: 14px;
  font-family: var(--font-mono);
  padding: 11px 14px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.15s;
}
.field-input:focus { border-color: var(--accent); }
.field-input--error { border-color: rgba(220,50,50,0.5); }

.login-btn {
  width: 100%;
  background: var(--accent);
  border: none;
  border-radius: 7px;
  color: var(--white);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  padding: 12px;
  transition: background 0.15s;
}
.login-btn:hover { background: var(--accent-dark); }

.login-footer {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 20px;
}

/* ─── Portal layout ──────────────────────────────────────────────── */
.portal {
  display: flex;
  height: 100%;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  overflow: hidden;
  border-right: 1px solid var(--border-dark);
}

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border-dark);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  margin-bottom: 4px;
}

.logo .logo-text {
  font-size: 16px;
}

.logo-sub {
  color: var(--text-muted);
  font-size: 11px;
  padding-left: 34px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-dark3) transparent;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  padding: 8px 18px 4px;
}

.nav-item {
  display: block;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.3;
  padding: 5px 18px 5px 22px;
  text-decoration: none;
  border-radius: 0;
  transition: color 0.1s, background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item:hover { color: var(--text-light); background: var(--bg-dark2); }
.nav-item.active {
  color: var(--text-active);
  background: #1a3050;
  border-left: 2px solid var(--accent);
  padding-left: 20px;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 12px 18px;
  border-top: 1px solid var(--border-dark);
}

.logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  padding: 0;
  transition: color 0.15s;
}
.logout-btn:hover { color: var(--text-light); }

/* ─── Main content ───────────────────────────────────────────────── */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  background: var(--white);
}

.content-inner {
  max-width: 960px;
  padding: 48px 56px;
}

/* ─── Welcome / index ────────────────────────────────────────────── */
.welcome-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid #e2e8f0;
}

.welcome-hero h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--body-text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.welcome-sub {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 3px;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.doc-category-card {
  background: var(--body-bg);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 18px 20px;
}

.category-card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.category-doc-list {
  list-style: none;
}

.category-doc-list li {
  margin-bottom: 4px;
}

.category-doc-list a {
  color: var(--body-text);
  font-size: 13px;
  text-decoration: none;
  line-height: 1.4;
}
.category-doc-list a:hover { color: var(--accent); text-decoration: underline; }

/* ─── Document view ──────────────────────────────────────────────── */
.doc-header {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 2px solid #e2e8f0;
}

.breadcrumb {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.doc-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--body-text);
  letter-spacing: -0.4px;
  line-height: 1.25;
  margin-bottom: 6px;
}

.doc-meta {
  font-size: 12px;
  color: var(--text-mid);
}

/* ─── Rendered markdown ──────────────────────────────────────────── */
.doc-body { line-height: 1.75; color: #2d3748; }

.doc-body svg { display: block; }
.doc-body div[style*="overflow-x"] { margin: 1.5em 0; border-radius: 6px; }
.doc-body div[style*="overflow-x"] svg { border-radius: 6px; }

.doc-body h1, .doc-body h2, .doc-body h3, .doc-body h4 {
  color: var(--body-text);
  font-weight: 700;
  letter-spacing: -0.2px;
  margin-top: 2em;
  margin-bottom: 0.6em;
  line-height: 1.3;
}
.doc-body h1 { font-size: 22px; padding-bottom: 8px; border-bottom: 1px solid #e2e8f0; }
.doc-body h2 { font-size: 18px; padding-bottom: 6px; border-bottom: 1px solid #f0f4f8; }
.doc-body h3 { font-size: 15px; }
.doc-body h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); }

.doc-body p { margin-bottom: 1em; }

.doc-body a { color: var(--accent); text-decoration: none; }
.doc-body a:hover { text-decoration: underline; }

.doc-body ul, .doc-body ol {
  margin: 0.5em 0 1em 1.5em;
}
.doc-body li { margin-bottom: 0.3em; }

.doc-body code {
  background: #f0f4f8;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 1px 5px;
}

.doc-body pre {
  background: #1e2d40;
  border-radius: 8px;
  overflow-x: auto;
  padding: 18px 20px;
  margin: 1.2em 0;
}
.doc-body pre code {
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 13px;
  padding: 0;
}

.doc-body blockquote {
  border-left: 3px solid var(--accent);
  color: var(--text-dim);
  font-size: 14px;
  margin: 1em 0;
  padding: 10px 16px;
  background: #fff8f5;
  border-radius: 0 6px 6px 0;
}
.doc-body blockquote p { margin: 0; }

.doc-body table {
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 1em 0 1.5em;
  width: 100%;
}
.doc-body th {
  background: #f0f4f8;
  border: 1px solid #e2e8f0;
  color: var(--body-text);
  font-size: 11px;
  font-weight: 700;
  padding: 8px 12px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.doc-body td {
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  vertical-align: top;
}
.doc-body tr:nth-child(even) td { background: #f8fafc; }

.doc-body hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 2em 0;
}

.doc-body strong { font-weight: 600; color: var(--body-text); }
.doc-body del { color: var(--text-mid); }

/* ─── Criticality badges ─────────────────────────────────────────── */
.crit-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  line-height: 16px;
}
.crit-critical { background: #fee2e2; color: #991b1b; }
.crit-high     { background: #ffedd5; color: #9a3412; }
.crit-medium   { background: #fef9c3; color: #854d0e; }
.crit-low      { background: #dcfce7; color: #166534; }

/* ─── Sidebar top-level links (Dashboard, Assets) ───────────────── */
.sidebar-top-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 18px;
  text-decoration: none;
  transition: color 0.1s, background 0.1s;
}
.sidebar-top-link:hover { color: var(--text-light); background: var(--bg-dark2); }
.sidebar-top-link.active { color: var(--text-active); background: #1a3050; border-left: 2px solid var(--accent); padding-left: 16px; }
.top-link-icon { font-size: 11px; opacity: 0.6; }
.nav-divider { height: 1px; background: var(--border-dark); margin: 8px 18px; }

/* ─── Collapsible nav sections ───────────────────────────────────── */
.nav-section-toggle {
  width: 100%;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 4px 0;
  cursor: pointer;
  text-align: left;
}
.nav-section-toggle .nav-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  flex: 1;
}
.nav-count {
  color: var(--text-muted);
  font-size: 10px;
  background: var(--bg-dark3);
  border-radius: 8px;
  padding: 0 5px;
  line-height: 16px;
}
.chevron {
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.nav-section.collapsed .chevron { transform: rotate(-90deg); }
.nav-items { overflow: hidden; }
.nav-section.collapsed .nav-items { display: none; }

/* ─── Nav item with badge ────────────────────────────────────────── */
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.nav-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ─── Dashboard ─────────────────────────────────────────────────── */
.dash-header { margin-bottom: 28px; }
.dash-header h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 4px; }
.dash-subtitle { color: var(--text-dim); font-size: 14px; }

.stat-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--body-bg);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 20px;
  min-width: 100px;
  text-align: center;
}
.stat-num { font-size: 28px; font-weight: 700; color: var(--body-text); line-height: 1; margin-bottom: 4px; }
.stat-num.stat-red    { color: #dc2626; }
.stat-num.stat-yellow { color: #d97706; }
.stat-num.stat-green  { color: #16a34a; }
.stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

.alert { border-radius: 8px; padding: 12px 16px; font-size: 13px; margin-bottom: 28px; }
.alert-critical { background: #fee2e2; border: 1px solid #fca5a5; color: #7f1d1d; }

.dash-section { margin-bottom: 32px; }
.dash-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--body-text);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}
.dash-count {
  background: #e2e8f0;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  color: var(--text-dim);
  margin-left: auto;
}
.priority-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.priority-dot.priority-high   { background: #ef4444; }
.priority-dot.priority-medium { background: #f59e0b; }
.priority-dot.priority-low    { background: #22c55e; }

.question-table { display: flex; flex-direction: column; gap: 1px; }
.question-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 12px;
  background: var(--body-bg);
  border-radius: 6px;
  font-size: 13px;
}
.question-row:hover { background: #f0f4f8; }
.q-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mid);
  flex-shrink: 0;
  width: 28px;
}
.q-title { flex: 1; color: var(--body-text); line-height: 1.4; }
.q-gate {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  background: #e2e8f0;
  color: var(--text-dim);
  white-space: nowrap;
}
.q-gate.gate-pre-prototype   { background: #fee2e2; color: #991b1b; }
.q-gate.gate-prototype       { background: #ffedd5; color: #9a3412; }
.q-gate.gate-pre-certification { background: #fef9c3; color: #854d0e; }
.q-gate.gate-pre-launch      { background: #f0fdf4; color: #166534; }

/* ─── Assets gallery ─────────────────────────────────────────────── */
.asset-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}
.asset-card {
  background: var(--body-bg);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}
.asset-thumb {
  display: block;
  aspect-ratio: 16/10;
  overflow: hidden;
  background: #e2e8f0;
}
.asset-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}
.asset-thumb:hover img { transform: scale(1.03); }
.asset-name {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.asset-name a { color: var(--text-dim); text-decoration: none; }
.asset-name a:hover { color: var(--accent); }

.file-list { display: flex; flex-direction: column; gap: 2px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--body-bg);
  border-radius: 6px;
  text-decoration: none;
  color: var(--body-text);
  font-size: 13px;
  transition: background 0.1s;
}
.file-row:hover { background: #f0f4f8; }
.file-icon { color: var(--text-muted); font-size: 16px; }
.file-name { flex: 1; }
.file-action { color: var(--accent); font-size: 12px; }

.empty-state {
  background: var(--body-bg);
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 32px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}
.empty-state code {
  background: #e2e8f0;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
}
