:root {
  color-scheme: dark;
  --bg: #090909;
  --panel: #151412;
  --panel-soft: #201d17;
  --line: #514327;
  --text: #f4f0e6;
  --muted: #b9ad92;
  --gold: #d6b354;
  --gold-light: #ffe08a;
  --danger: #e18478;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(900px 480px at 82% -12%, #292316 0%, var(--bg) 64%);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, select { font: inherit; }
.topbar {
  min-height: 58px;
  padding: 10px max(18px, calc((100vw - 1100px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 9, 9, .96);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { color: var(--gold); font-size: 26px; font-weight: 800; letter-spacing: 2px; text-decoration: none; }
.brand span { color: var(--text); font-size: 15px; letter-spacing: 1px; margin-left: 7px; vertical-align: 2px; }
.head-right { display: flex; align-items: center; gap: 12px; }
.role-chip { border: 1px solid #715c2b; color: var(--gold-light); background: var(--panel-soft); border-radius: 999px; padding: 3px 9px; font-size: 10px; letter-spacing: 1px; }
.identity, .muted { color: var(--muted); font-size: 13px; }
.text-button { border: 0; padding: 5px; color: var(--muted); background: transparent; text-decoration: underline; cursor: pointer; }
main { width: min(1100px, 100%); margin: 0 auto; padding: 20px 16px 44px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: 0 12px 34px rgba(0,0,0,.25); }
.login-panel { max-width: 420px; margin: 8vh auto; }
.eyebrow { margin: 0 0 3px; color: var(--gold); font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 24px; }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 0 0 7px; font-size: 15px; }
.login-panel .muted { margin: 7px 0 18px; }
.form-stack, .form-grid { display: grid; gap: 12px; }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
input, select {
  width: 100%; min-height: 40px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 7px;
  background: #0d0c0a; color: var(--text);
}
input:focus, select:focus { outline: 1px solid var(--gold); border-color: var(--gold); }
.primary, .secondary {
  min-height: 40px; border-radius: 7px; padding: 8px 14px; font-weight: 650; cursor: pointer;
}
.primary { border: 0; color: #17130a; background: linear-gradient(180deg, #e0c46e, #b28b36); }
.primary:disabled { opacity: .55; cursor: default; }
.secondary { color: var(--text); border: 1px solid var(--line); background: var(--panel-soft); }
.nav { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 12px; }
.nav-item { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 7px; padding: 8px 17px; background: var(--panel-soft); color: var(--muted); cursor: pointer; }
.nav-item.active { color: #17130a; background: var(--gold); border-color: var(--gold-light); font-weight: 700; }
.page { min-height: 260px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.metrics article { display: grid; gap: 6px; min-height: 88px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-soft); }
.metrics article span { color: var(--muted); font-size: 12px; }
.metrics strong { font-size: 23px; }
.metrics i { font-style: normal; }
.metrics small { color: var(--gold-light); font-size: 11px; font-weight: 500; }
.compact { margin: 9px 0 0; }
.operation { margin: 10px 0; border: 1px solid var(--line); border-radius: 8px; background: #11100e; }
.operation summary { padding: 11px 13px; cursor: pointer; color: var(--gold-light); font-size: 14px; }
.operation[open] summary { border-bottom: 1px solid #30291b; }
.operation > form, .operation > .tree { padding: 13px; }
.message { margin: 9px 0 0; font-size: 13px; }
.message.error { color: var(--danger); }
.message.ok { color: var(--gold-light); }
.report-filter { display: grid; grid-template-columns: 1.25fr 1fr 1fr auto; align-items: end; gap: 10px; }
.report-actions { display: flex; gap: 7px; }
.table-wrap { width: 100%; overflow: auto; margin-top: 13px; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 8px 9px; text-align: left; border-bottom: 1px solid #30291b; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: var(--panel-soft); }
.tree ul { list-style: none; margin: 5px 0 5px 15px; padding-left: 12px; border-left: 1px dashed var(--line); }
.tree li { margin: 5px 0; }
.tree-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: baseline; }
.tree-tag { color: var(--gold-light); font-size: 11px; }
.member-directory { margin: 14px 0; }
.directory-head { margin: 0 0 9px; }
.directory-head h3 { margin-bottom: 0; font-size: 17px; }
.directory-search { max-width: 480px; margin-bottom: 9px; }
.member-directory .table-wrap { margin-top: 0; }
.member-directory tbody tr:last-child td { border-bottom: 0; }
.risk-summary { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.single-row { max-width: 520px; }
[hidden] { display: none !important; }

@media (max-width: 680px) {
  main { padding: 12px 10px 28px; }
  .panel { padding: 14px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics strong { font-size: 21px; }
  .report-filter { grid-template-columns: 1fr 1fr; }
  .report-filter label:first-child, .report-actions { grid-column: 1 / -1; }
  .report-actions > button { flex: 1; }
  .identity { display: none; }
}
