:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --line: #d5dbe5;
  --text: #182230;
  --muted: #697386;
  --accent: #0e766a;
  --accent-dark: #0b5f56;
  --accent-blue: #2563eb;
  --danger: #b42318;
  --warning: #a15c07;
  --blue: #175cd3;
  --sidebar: #101624;
  --radius: 8px;
  --shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

a {
  color: var(--accent-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a.primary-button,
a.secondary-button,
a.ghost-button {
  min-height: 38px;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background-color: #111827;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: var(--sidebar);
  color: #f8fafc;
  border-right: 1px solid #0b1020;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 8px 18px;
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #0f766e;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.brand-mark.large {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.nav-item {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 10px;
  margin: 4px 0;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 600;
  letter-spacing: 0;
}

.nav-item.active,
.nav-item:hover {
  background: #263244;
  color: #ffffff;
  text-decoration: none;
}

.main {
  min-width: 0;
  padding: 28px;
}

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

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.page-title {
  margin-top: 3px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 30px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.login-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-header h1 {
  margin: 0;
  font-size: 24px;
}

.login-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.flash {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
}

.flash.error {
  border-color: #fecdca;
  background: #fffbfa;
  color: var(--danger);
}

.flash.success {
  border-color: #a6f4c5;
  background: #f6fef9;
  color: #067647;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  min-height: 104px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-blue));
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.section-heading,
.detail-head,
.toolbar,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading {
  min-height: 42px;
  margin: 4px 0 10px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 17px;
}

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.toolbar input[type="search"] {
  flex: 1 1 280px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.actions,
.detail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.strong-link {
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag,
.severity,
.classification,
.doc-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag {
  background: #eef2f6;
  color: #344054;
}

.severity.info {
  background: #eff8ff;
  color: var(--blue);
}

.severity.low {
  background: #ecfdf3;
  color: #067647;
}

.severity.medium {
  background: #fffaeb;
  color: var(--warning);
}

.severity.high {
  background: #fff1f3;
  color: #c01048;
}

.severity.critical {
  background: #fef3f2;
  color: var(--danger);
}

.classification.internal {
  background: #f0f9ff;
  color: #026aa2;
}

.classification.restricted {
  background: #fff7ed;
  color: #c2410c;
}

.classification.confidential {
  background: #fdf2fa;
  color: #c11574;
}

.doc-status.draft {
  background: #eef2f6;
  color: #344054;
}

.doc-status.published {
  background: #ecfdf3;
  color: #067647;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-dark);
  text-decoration: none;
}

.secondary-button {
  background: #ffffff;
  border-color: var(--accent);
  color: var(--accent-dark);
}

.secondary-button:hover,
.ghost-button:hover {
  background: #eef6f5;
  text-decoration: none;
}

.ghost-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
}

.danger-button {
  background: #ffffff;
  border-color: #fecdca;
  color: var(--danger);
}

.danger-button:hover {
  background: #fffbfa;
}

.small {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
}

.wide {
  width: 100%;
}

.editor-form,
.plain-section,
.meta-grid,
.empty-state,
.catalog-card,
.post-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.editor-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.catalog-grid,
.post-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.catalog-card,
.post-card {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.catalog-card-head,
.post-card-top,
.catalog-actions,
.post-taxonomy {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.catalog-card-head,
.post-card-top,
.catalog-actions {
  justify-content: space-between;
}

.catalog-card-head {
  align-items: center;
}

.catalog-actions {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.post-taxonomy {
  flex-wrap: wrap;
  align-items: center;
}

.post-title {
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
}

.post-title:hover {
  color: var(--accent-dark);
}

.catalog-summary {
  margin: 0;
  color: #475467;
  overflow-wrap: anywhere;
}

.poc-signature {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.poc-signature span {
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9d2df;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  min-height: 116px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.22);
  border-color: var(--accent);
}

.detail-head {
  align-items: flex-start;
  margin-bottom: 16px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 16px;
}

.meta-grid div {
  padding: 14px;
  border-right: 1px solid var(--line);
}

.meta-grid div:last-child {
  border-right: 0;
}

.meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.meta-grid strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.plain-section {
  padding: 18px;
  margin-bottom: 16px;
}

.plain-section h2 {
  margin-bottom: 12px;
}

.plain-section p {
  margin: 0;
  white-space: pre-wrap;
}

.code-block,
.doc-block {
  max-height: 64vh;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #101828;
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
}

.doc-block {
  background: #ffffff;
  color: var(--text);
  white-space: pre-wrap;
}

.cm-shell {
  width: 100%;
}

.cm-shell .cm-editor {
  width: 100%;
}

.code-viewer-frame .cm-editor {
  max-height: 64vh;
}

.code-viewer-frame .cm-scroller {
  overflow: auto;
}

.markdown-body {
  color: var(--text);
  overflow-wrap: anywhere;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 24px 0 12px;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body table,
.markdown-body pre {
  margin: 0 0 14px;
}

.markdown-body blockquote {
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--line);
  color: #475467;
}

.markdown-body pre {
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  background: #101828;
  color: #f8fafc;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line);
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

code {
  padding: 2px 5px;
  border-radius: 6px;
  background: #eef2f6;
  color: #344054;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar nav {
    display: flex;
    overflow-x: auto;
    gap: 6px;
  }

  .nav-item {
    min-width: max-content;
  }

  .stats-grid,
  .split-grid,
  .form-grid,
  .meta-grid,
  .catalog-grid,
  .post-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 16px;
  }

  .stats-grid,
  .split-grid,
  .form-grid,
  .meta-grid,
  .catalog-grid,
  .post-grid,
  .poc-signature {
    grid-template-columns: 1fr;
  }

  .meta-grid div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .meta-grid div:last-child {
    border-bottom: 0;
  }

  .topbar,
  .detail-head,
  .detail-actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .user-menu,
  .actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
