:root {
  --bg: #f7f8f5;
  --panel: #ffffff;
  --text: #17211a;
  --muted: #687168;
  --line: #dfe4dc;
  --accent: #186a5d;
  --accent-strong: #0d4d42;
  --accent-soft: #e4f1ed;
  --warn: #a4581b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 245, 0.94);
  backdrop-filter: blur(12px);
}

.brand,
.nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  color: var(--text);
  font-weight: 700;
}

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

.brand-mark {
  width: 24px;
  height: 24px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background:
    linear-gradient(90deg, transparent 45%, var(--accent) 45% 55%, transparent 55%),
    linear-gradient(0deg, transparent 63%, #c9a227 63% 74%, transparent 74%),
    linear-gradient(0deg, transparent 32%, #7b9c4d 32% 42%, transparent 42%);
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
}

.nav a[aria-current="page"] {
  color: var(--text);
  background: var(--accent-soft);
}

.logout-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

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

.nav-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.nav-button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.shell {
  width: min(1180px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 30px 0 56px;
}

.page-head,
.section-title,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-head {
  margin-bottom: 22px;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.alert {
  margin-bottom: 18px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.alert.error {
  border-color: #dfb39a;
  color: #7e3615;
  background: #fff4ed;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  border-color: var(--accent);
  text-decoration: none;
}

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

.button.ghost {
  color: var(--muted);
}

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

.metric {
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1.1;
}

.metric .metric-text {
  font-size: 17px;
  line-height: 1.35;
  word-break: break-word;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  gap: 24px;
  align-items: start;
}

.section-title {
  margin-bottom: 10px;
}

.section-title h2,
.side-panel h2 {
  margin: 0;
  font-size: 18px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

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

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  background: #fbfcfa;
}

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

.filter-bar {
  display: grid;
  grid-template-columns: 150px minmax(150px, 1fr) minmax(160px, 1fr) minmax(140px, 0.8fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

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

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(228, 241, 237, 0.55), rgba(247, 248, 245, 0) 260px),
    var(--bg);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 390px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(23, 33, 26, 0.08);
}

.login-title {
  margin: 28px 0 18px;
}

.login-title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

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

.login-submit {
  width: 100%;
  margin-top: 4px;
}

.form-error {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid #e0b69a;
  border-radius: 6px;
  color: #873d17;
  background: #fff4ed;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 22px;
}

.meta-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

dd {
  margin: 5px 0 0;
  word-break: break-word;
}

.path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.markdown {
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.markdown.preview {
  max-height: 520px;
  overflow: hidden;
}

.markdown h1,
.markdown h2,
.markdown h3 {
  line-height: 1.35;
}

.markdown h1 {
  margin-top: 0;
  font-size: 24px;
}

.markdown h2 {
  margin-top: 24px;
  font-size: 19px;
}

.markdown h3 {
  margin-top: 18px;
  font-size: 16px;
}

.markdown p,
.markdown li {
  color: #263027;
}

.side-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.side-panel h2 + .link-list {
  margin-top: 8px;
}

.link-list {
  display: grid;
  gap: 8px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}

.link-list li {
  display: grid;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.link-list small,
.empty {
  color: var(--muted);
}

@media (max-width: 860px) {
  .topbar,
  .page-head,
  .section-title {
    align-items: flex-start;
  }

  .topbar,
  .page-head {
    flex-direction: column;
  }

  .nav {
    flex-wrap: wrap;
  }

  .topbar {
    padding: 12px 18px;
  }

  .shell {
    width: min(100vw - 24px, 720px);
    padding-top: 22px;
  }

  .metric-grid,
  .split,
  .meta-grid,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}
