:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-soft: #eef4f8;
  --text: #1d252d;
  --muted: #637083;
  --line: #d9e0ea;
  --accent: #126f82;
  --accent-strong: #0d5968;
  --accent-soft: #dff3f6;
  --code-bg: #18222d;
  --code-text: #edf7fb;
  --warn: #9b5b00;
  --shadow: 0 10px 30px rgba(20, 32, 45, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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.6;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.auth-shell {
  display: grid;
  min-height: calc(100vh - 72px);
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.auth-brand h1 {
  margin: 0 0 4px;
  font-size: 26px;
  line-height: 1.2;
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
  color: var(--text);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #1b7f91;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.search {
  position: relative;
  width: min(560px, 100%);
}

.search input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.search input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.search-results {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-results a {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--text);
}

.search-results a:hover,
.search-results a:focus {
  background: var(--panel-soft);
  text-decoration: none;
}

.search-results strong {
  display: block;
  margin-bottom: 2px;
}

.search-results small {
  display: block;
  color: var(--muted);
  line-height: 1.4;
}

.search-empty {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
}

.user-menu {
  position: relative;
  margin-left: auto;
  color: var(--text);
}

.user-menu strong,
.user-menu small {
  display: block;
}

.user-menu small {
  color: var(--muted);
  font-size: 12px;
}

.user-dropdown {
  position: relative;
}

.user-dropdown summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  text-align: right;
}

.user-dropdown summary::-webkit-details-marker {
  display: none;
}

.user-dropdown summary::after {
  content: "⌄";
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.user-dropdown[open] summary,
.user-dropdown summary:hover {
  background: var(--panel-soft);
}

.user-dropdown-panel {
  position: absolute;
  top: 52px;
  right: 0;
  z-index: 30;
  width: 220px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.user-dropdown-panel a,
.user-dropdown-panel button {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.user-dropdown-panel a:hover,
.user-dropdown-panel button:hover {
  background: var(--panel-soft);
  text-decoration: none;
}

.user-dropdown-panel form {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.flash-wrap {
  max-width: 1480px;
  margin: 18px auto 0;
  padding: 0 28px;
}

.flash {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.flash + .flash {
  margin-top: 8px;
}

.flash.error {
  border-color: #e5a7a7;
  background: #fff2f2;
  color: #8a1f1f;
}

.flash.success {
  border-color: #a8d9c6;
  background: #eefbf6;
  color: #13543b;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 240px;
  gap: 28px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px;
}

.sidebar,
.toc {
  align-self: start;
  position: sticky;
  top: 96px;
}

.sidebar {
  max-height: calc(100vh - 116px);
  overflow: auto;
  padding-right: 8px;
}

.nav-group {
  margin-bottom: 22px;
}

.nav-group h2,
.toc h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-group a,
.toc a,
.toc-empty {
  display: block;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.nav-group a:hover,
.toc a:hover,
.nav-group a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-decoration: none;
}

.nav-meta {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.content {
  min-width: 0;
}

.page-actions,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.page-actions code,
.section-header code,
.table-row code {
  display: inline-block;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

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

.primary-button:hover {
  background: var(--accent-strong);
  color: #fff;
  text-decoration: none;
}

.secondary-button {
  background: #fff;
  border-color: var(--line);
  color: var(--accent-strong);
}

.secondary-button:hover {
  background: var(--panel-soft);
  text-decoration: none;
}

.doc {
  padding: 44px 52px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.narrow-panel {
  max-width: 760px;
}

.editor-panel {
  max-width: 980px;
}

.section-header h1 {
  margin: 0 0 4px;
  font-size: 30px;
  line-height: 1.2;
}

.section-header p {
  margin: 0;
  color: var(--muted);
}

.table-list {
  border-top: 1px solid var(--line);
}

.table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.row-title {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-weight: 800;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.role-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.role-pill {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill.active {
  background: #eefbf6;
  color: #13543b;
}

.status-pill.inactive {
  background: #f0f2f5;
  color: var(--muted);
}

.form-stack {
  display: grid;
  gap: 16px;
}

.form-stack label {
  display: grid;
  gap: 6px;
}

.form-stack label > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-stack input,
.form-stack select,
.form-stack textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.form-stack input,
.form-stack select {
  min-height: 42px;
  padding: 0 12px;
}

.form-stack textarea {
  min-height: 520px;
  padding: 14px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.55;
}

.form-stack input:focus,
.form-stack select:focus,
.form-stack textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.check-row {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.doc h1,
.doc h2,
.doc h3,
.doc h4 {
  line-height: 1.24;
}

.doc h1 {
  margin: 0 0 24px;
  font-size: 38px;
}

.doc h2 {
  margin: 40px 0 14px;
  padding-top: 8px;
  font-size: 26px;
}

.doc h3 {
  margin: 28px 0 10px;
  font-size: 20px;
}

.doc p,
.doc ul,
.doc ol,
.doc blockquote,
.doc pre {
  margin-top: 0;
  margin-bottom: 18px;
}

.doc li + li {
  margin-top: 6px;
}

.doc code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef2f5;
  color: #27313d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.doc pre {
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
}

.doc pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.doc blockquote {
  padding: 12px 16px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: #27424b;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.page-footer code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.toc {
  max-height: calc(100vh - 116px);
  overflow: auto;
}

.toc .toc-h3 {
  padding-left: 22px;
}

.toc-empty {
  margin: 0;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 820px) {
  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px;
  }

  .brand {
    min-width: 0;
  }

  .layout {
    display: block;
    padding: 16px;
  }

  .user-menu {
    width: 100%;
    margin-left: 0;
  }

  .user-dropdown summary {
    justify-content: space-between;
    text-align: left;
  }

  .user-dropdown-panel {
    left: 0;
    right: auto;
    width: 100%;
  }

  .sidebar {
    position: static;
    max-height: none;
    margin-bottom: 18px;
    padding: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .nav-group {
    margin-bottom: 14px;
  }

  .doc {
    padding: 28px 20px;
  }

  .panel {
    padding: 22px 18px;
  }

  .page-actions,
  .section-header,
  .table-row {
    display: block;
  }

  .action-row,
  .status-line {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .doc h1 {
    font-size: 30px;
  }

  .doc h2 {
    font-size: 23px;
  }

  .page-footer {
    display: block;
  }

  .page-footer span {
    display: block;
    margin-top: 6px;
  }
}
