:root {
  --bg: #f3f5f7;
  --panel: #fff;
  --text: #17212b;
  --muted: #667483;
  --line: #dfe5ea;
  --header: #102d47;
  --header-active: #214f70;
  --primary: #087fca;
  --primary-dark: #066ba9;
  --soft: #e8f3fa;
  --ok: #18794e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: stretch;
  background: var(--header);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}
.topbar-brand {
  width: 230px;
  flex: 0 0 230px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 24px;
  font-size: 18px;
  white-space: nowrap;
}
.topbar-brand span { color: #9dc7df; font-size: 13px; font-weight: 600; }
.topnav { display: flex; align-items: stretch; min-width: 0; }
.topnav a {
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 3px solid transparent;
  color: #eaf2f7;
  font-size: 15px;
  white-space: nowrap;
}
.topnav a:hover { background: rgba(255, 255, 255, .07); }
.topnav a.active { background: var(--header-active); border-bottom-color: #3fb4e9; color: #fff; }

.account-links {
  margin-left: auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  font-size: 13px;
}
.account-links > a:not(.logout-link):hover { text-decoration: underline; }
.logout-link {
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 4px;
  line-height: 1.3;
}
.logout-link:hover { background: #fff; color: var(--header); }

.workspace-shell { min-height: calc(100vh - 64px); display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.context-sidebar {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: #fff;
}
.side-title { padding: 0 10px 18px; font-size: 16px; font-weight: 700; }
.side-group + .side-group { margin-top: 22px; }
.side-label { padding: 0 10px 6px; color: #7990a1; font-size: 12px; font-weight: 650; }
.side-nav { display: grid; gap: 3px; }
.side-nav a { padding: 9px 11px; border-radius: 6px; }
.side-nav a:hover { background: #f2f6f8; }
.side-nav a.active { background: var(--soft); color: #066da8; font-weight: 650; }

.main { min-width: 0; padding: 28px; }
.main-full { min-height: 100vh; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 27px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

.app-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; max-width: 980px; }
.app-card {
  min-height: 132px;
  display: flex;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  transition: border-color .15s, box-shadow .15s;
}
.app-card:hover { border-color: #a9ccdf; box-shadow: 0 8px 22px rgba(23, 33, 43, .07); }
.app-card h2 { margin: 0 0 5px; font-size: 18px; }
.app-card p { margin: 0 0 14px; color: var(--muted); }
.app-card span { color: #066da8; font-weight: 650; }
.app-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--header);
  color: #fff;
  font-weight: 800;
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid #cdd6dd;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.btn:hover { border-color: #99adba; background: #f8fafb; }
.btn.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn.primary:hover { border-color: var(--primary-dark); background: var(--primary-dark); }
.btn.full { width: 100%; margin-top: 10px; }

.search { display: flex; gap: 9px; max-width: 720px; margin-bottom: 16px; }
.search input, input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cdd6dd;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(8, 127, 202, .18); border-color: var(--primary); }

.table-card, .form-card, .detail-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.table-card table { width: 100%; border-collapse: collapse; }
.table-card th, .table-card td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table-card tr:last-child td { border-bottom: 0; }
.table-card th { background: #f2f6f8; color: #445564; font-size: 12px; }
.table-card tbody tr:hover { background: #fbfcfd; }
.muted { color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #edf0f2; font-size: 12px; }
.badge.ok { background: #e8f6ef; color: var(--ok); }

.form-card { max-width: 900px; padding: 22px; }
.form-card.compact { width: 330px; height: max-content; }
.form-card h2 { margin-top: 0; font-size: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field label { display: block; margin-bottom: 6px; font-weight: 600; }
.field input[type=checkbox] { width: auto; }
.access-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.access-item { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; }
.access-item input { width: auto; }
.access-item small { display: block; color: var(--muted); }
.actions { display: flex; gap: 9px; margin-top: 22px; }
.split { display: flex; align-items: flex-start; gap: 20px; }
.grow { min-width: 0; flex: 1; }
.detail-card { max-width: 780px; padding: 22px; }
.detail-card dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; }
.detail-card dt { color: var(--muted); }
.detail-card dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }

.manual-document {
  width: min(980px, 100%);
  max-width: 980px;
  padding: 32px 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.manual-main {
  min-height: calc(100vh - 64px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px;
}
.manual-document h1 { margin: 0 0 10px; font-size: 28px; }
.manual-document h2 { margin: 34px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 21px; }
.manual-document h3 { margin: 26px 0 10px; font-size: 17px; }
.manual-document p, .manual-document li { color: #344451; }
.manual-document a { color: #066da8; text-decoration: underline; }
.manual-document code { padding: 2px 5px; border-radius: 4px; background: #f1f4f6; }
.manual-document pre { overflow-x: auto; padding: 14px; border-radius: 6px; background: #17212b; color: #f4f7f9; }
.manual-document pre code { padding: 0; background: transparent; color: inherit; }
.manual-document table { width: 100%; border-collapse: collapse; }
.manual-document th, .manual-document td { padding: 10px 12px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.manual-document th { background: #f2f6f8; }
.manual-document blockquote { margin: 16px 0; padding: 2px 16px; border-left: 4px solid var(--primary); background: #f4f9fc; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(23, 33, 43, .1);
}
.brand { font-size: 19px; font-weight: 750; }
.brand span { display: block; color: #778796; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.login-card h1 { margin: 24px 0 4px; }
.login-card label { display: block; margin: 14px 0 6px; font-weight: 600; }
.notice { margin: 12px 0; padding: 10px; border: 1px solid #f4d9a6; border-radius: 6px; background: #fff7e8; }
.tiny { margin-top: 16px; font-size: 12px; }
.messages { margin-bottom: 16px; }
.message { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.empty, .empty-page { padding: 28px; color: var(--muted); }
.empty-page { max-width: 560px; border-radius: 8px; background: #fff; }
hr { margin: 24px 0; border: 0; border-top: 1px solid var(--line); }

@media (max-width: 840px) {
  .topbar { position: static; height: auto; flex-wrap: wrap; }
  .topbar-brand { width: auto; height: 56px; flex-basis: auto; padding: 0 16px; }
  .account-links { padding: 0 12px; }
  .topnav { order: 3; width: 100%; height: 46px; overflow-x: auto; border-top: 1px solid rgba(255, 255, 255, .1); }
  .topnav a { padding: 0 16px; }
  .workspace-shell { display: block; min-height: calc(100vh - 102px); }
  .context-sidebar { position: static; width: 100%; height: auto; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-title, .side-label { display: none; }
  .side-nav { display: flex; gap: 6px; overflow-x: auto; }
  .side-nav a { white-space: nowrap; }
  .main { padding: 20px 16px; }
  .manual-main { min-height: calc(100vh - 102px); padding: 20px 16px; }
  .page-head { align-items: center; }
  .page-head h1 { font-size: 24px; }
  .form-grid, .access-grid { grid-template-columns: 1fr; }
  .split { display: block; }
  .form-card.compact { width: 100%; max-width: none; margin-bottom: 18px; }
}

@media (max-width: 520px) {
  .topbar-brand span { display: none; }
  .account-links { gap: 8px; font-size: 12px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head .btn { width: 100%; }
  .search { align-items: stretch; flex-direction: column; }
  .table-card { overflow-x: auto; }
  .table-card table { min-width: 620px; }
  .detail-card dl { grid-template-columns: 1fr; gap: 4px; }
  .detail-card dd { margin-bottom: 10px; }
  .manual-document { padding: 24px 18px; overflow-x: auto; }
}
