:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-soft: #eef4f2;
  --text: #17211f;
  --muted: #66736f;
  --line: #dce5e2;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #b7791f;
  --danger: #b42318;
  --shadow: 0 18px 42px rgba(30, 48, 45, 0.09);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Noto Sans CJK SC",
    system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.brand,
.nav-item {
  width: 100%;
  border: 0;
  text-align: left;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  padding: 24px 18px;
  background: #132420;
  color: #f7fbfa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 8px;
  background: transparent;
  color: #f7fbfa;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #e5f3ee;
  color: var(--primary-dark);
  font-weight: 800;
}

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

.brand small {
  margin-top: 2px;
  color: #abc0bb;
  font-size: 12px;
}

.nav-section,
.admin-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.nav-item,
.ghost-button {
  display: flex;
  align-items: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #d7e5e2;
  text-decoration: none;
  background: transparent;
}

.nav-item {
  gap: 10px;
  padding: 0 12px;
}

.nav-item.active,
.nav-item:hover,
.ghost-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: #a6d6cf;
}

.admin-panel {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.ghost-button {
  justify-content: flex-start;
  width: 100%;
  padding: 0 10px;
}

.main {
  display: grid;
  gap: 22px;
  align-content: start;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

.user-chip {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: #dff1ec;
  color: var(--primary-dark);
  font-weight: 800;
}

.user-chip small {
  margin-top: 2px;
  color: var(--muted);
}

.search-band {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 520px);
  gap: 20px;
  align-items: center;
  padding: 22px;
  border-radius: 8px;
  background: #dfece8;
}

.page-view {
  display: none;
  gap: 22px;
}

.page-view.active {
  display: grid;
}

.search-band p {
  max-width: 700px;
  margin: 8px 0 0;
  color: #47625c;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
}

.search-form input {
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #bdd0cb;
  border-radius: 8px;
  background: #ffffff;
}

.search-form button {
  height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.primary-button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

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

.metric-card,
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

.metric-card strong {
  font-size: 28px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.72fr);
  gap: 22px;
}

.panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

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

.category-tile {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 4px 10px;
  align-items: center;
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: left;
}

.category-tile.active,
.category-tile:hover {
  border-color: #8fc7bd;
  background: #eef8f5;
}

.category-tile strong,
.category-tile small {
  min-width: 0;
}

.category-tile small {
  grid-column: 2;
  color: var(--muted);
}

.tile-icon {
  display: grid;
  grid-row: span 2;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 800;
}

.policy {
  background: #0f766e;
}

.dept {
  background: #2563eb;
}

.process {
  background: #b7791f;
}

.starter {
  background: #7c3aed;
}

.tech {
  background: #475569;
}

.form {
  background: #be123c;
}

.preview-panel {
  min-width: 0;
}

.document-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.preview-toolbar div {
  display: flex;
  gap: 8px;
}

.preview-page {
  min-height: 230px;
  margin: 18px;
  padding: 22px;
  border: 1px solid #d7dfdc;
  border-radius: 6px;
  background: #ffffff;
}

.preview-page p,
.preview-page li {
  color: #4b5f5a;
  line-height: 1.7;
}

.meta-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
}

.meta-list div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
}

.meta-list dt {
  color: var(--muted);
}

.meta-list dd {
  margin: 0;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.filter.active,
.filter:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.api-status {
  display: inline-flex;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.api-status.success {
  color: var(--primary-dark);
}

.api-status.error {
  color: var(--danger);
}

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

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

.document-form input,
.document-form select,
.document-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.document-form input,
.document-form select {
  height: 40px;
  padding: 0 11px;
}

.document-form textarea {
  resize: vertical;
  padding: 10px 11px;
}

.form-wide {
  grid-column: 1 / -1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 28, 25, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(15, 28, 25, 0.28);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 0;
}

.modal .document-form {
  padding: 20px;
}

.table-wrap {
  overflow-x: auto;
}

.page-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfece8;
}

.page-hero p:last-child {
  max-width: 760px;
  margin: 8px 0 0;
  color: #47625c;
}

.department-grid,
.template-grid,
.settings-grid,
.permission-matrix,
.process-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.process-board {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.department-card,
.template-grid article,
.settings-grid article,
.permission-matrix article,
.process-board article {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.department-card span,
.department-card small,
.template-grid span,
.settings-grid span,
.permission-matrix span,
.process-board span,
.process-board p {
  color: var(--muted);
}

.template-grid button {
  justify-self: start;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--primary-dark);
  font-weight: 700;
}

.workflow-list {
  display: grid;
  gap: 14px;
}

.workflow-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workflow-item > span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #dff1ec;
  color: var(--primary-dark);
  font-weight: 800;
}

.workflow-item p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

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

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

td strong,
td span {
  display: block;
}

td > span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.secure {
  background: #dff1ec;
  color: #0f5d55;
}

.status-pill.public {
  background: #e8eefc;
  color: #244c9c;
}

.status-pill.locked {
  background: #fde8e6;
  color: var(--danger);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .nav-section {
    grid-auto-columns: minmax(120px, 1fr);
    grid-auto-flow: column;
    grid-template-columns: none;
    overflow-x: auto;
    width: 100%;
  }

  .admin-panel {
    display: none;
  }

  .content-grid,
  .search-band {
    grid-template-columns: 1fr;
  }

  .department-grid,
  .template-grid,
  .settings-grid,
  .permission-matrix,
  .process-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .main {
    height: auto;
    overflow: visible;
    padding: 18px;
  }

  .topbar,
  .panel-heading,
  .page-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-chip {
    width: 100%;
  }

  .metric-grid,
  .category-grid {
    grid-template-columns: 1fr 1fr;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .search-form button {
    width: 100%;
  }

  .primary-button {
    width: 100%;
  }

  .document-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .metric-grid,
  .category-grid,
  .department-grid,
  .template-grid,
  .settings-grid,
  .permission-matrix,
  .process-board {
    grid-template-columns: 1fr;
  }

  .preview-page {
    margin: 12px;
    padding: 16px;
  }

  .meta-list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
