:root {
  color-scheme: light;
  --paper: #f1f5f0;
  --surface: #fff;
  --rail: #102a20;
  --rail-text: #d2e2d7;
  --ink: #153024;
  --muted: #576b60;
  --line: #dce7de;
  --mint: #eaf5e9;
  --lime: #d4ff57;
  --green: #285e41;
  --focus: #487923;
  font-family: "PingFang SC", "Microsoft YaHei", "Avenir Next", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 280px; margin: 0; background: var(--paper); color: var(--ink); }
body, h1, h2, p { margin-block-start: 0; }
button, input, select { font: inherit; }
input, select { color: var(--ink); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.boot, .noscript {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #f4f9f0;
  font-family: "Avenir Next", system-ui, sans-serif;
  font-size: 1.16rem;
  font-weight: 850;
  letter-spacing: .06em;
  line-height: 1;
  white-space: nowrap;
}

.brand strong { color: var(--lime); font-weight: inherit; }
.brand-mark {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 32px;
  aspect-ratio: 1;
}

.brand-mark::before, .brand-mark::after {
  position: absolute;
  content: "";
}
.brand-mark::before {
  inset: 0;
  background: linear-gradient(135deg, #efffae, var(--lime) 56%, #72ae38);
  clip-path: polygon(evenodd,
    27% 10%, 75% 10%, 90% 23%, 90% 49%, 74% 63%, 51% 63%,
    39% 88%, 13% 88%, 37% 34%, 26% 34%, 19% 46%, 8% 46%, 27% 10%,
    53% 23%, 73% 36%, 53% 49%, 53% 23%, 27% 10%);
}
.brand-mark::after {
  top: 62%;
  left: 70%;
  width: 18%;
  height: 16%;
  background: #faca54;
  clip-path: polygon(30% 0, 100% 0, 66% 100%, 0 100%);
}

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(370px, 1.1fr);
}
.auth-brand {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-direction: column;
  overflow: hidden;
  padding: clamp(24px, 4vw, 60px);
  background:
    radial-gradient(ellipse at 49% 54%, #254d34, transparent 72%),
    #0e241b;
}
.auth-brand > .brand { font-size: 1.42rem; z-index: 1; }
.auth-brand > .brand .brand-mark { width: 39px; }
.auth-art {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(90deg, rgb(200 238 158 / 9%) 1px, transparent 1px),
    linear-gradient(rgb(200 238 158 / 9%) 1px, transparent 1px);
  background-size: 42px 42px;
  background-position: center;
  mask-image: radial-gradient(ellipse at center, #000 22%, transparent 75%);
}
.auth-art .brand-mark {
  width: clamp(142px, 24vw, 285px);
  filter: drop-shadow(0 18px 56px rgb(193 254 83 / 26%));
}
.auth-environment, .sidebar-environment { color: #c4d7ca; font-size: .875rem; }
.auth-environment { z-index: 1; }
.auth-workspace { display: grid; place-items: center; padding: clamp(22px, 6vw, 78px); }
.auth-card {
  width: min(100%, 460px);
  padding: clamp(24px, 4.5vw, 52px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 18px 56px rgb(26 51 38 / 8%);
}
.auth-card h1 { margin-bottom: 30px; font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.04em; }
.auth-card .primary { width: 100%; margin-top: 11px; }

.shell { display: grid; min-height: 100vh; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100dvh;
  padding: 30px 16px 20px;
  background: linear-gradient(153deg, #18392b, var(--rail) 58%, #0e2219);
  color: var(--rail-text);
}
.sidebar-brand { margin: 0 9px 36px; }
.sidebar-caption { padding: 8px 0 0 42px; color: #bed2c4; font-size: .875rem; }
#navigation { display: grid; gap: 5px; }
#navigation a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
#navigation a:hover { background: rgb(255 255 255 / 6%); color: #fff; }
#navigation a[aria-current="page"] {
  border-color: rgb(212 255 87 / 25%);
  background: rgb(212 255 87 / 12%);
  color: #e7ffac;
}
#navigation a:focus-visible { outline-color: var(--lime); }
.nav-icon { position: relative; width: 17px; height: 17px; flex: 0 0 auto; }
.nav-icon::before, .nav-icon::after { position: absolute; content: ""; }
.icon-players::before { top: 1px; left: 6px; width: 6px; height: 6px; border: 1.5px solid; border-radius: 50%; }
.icon-players::after { bottom: 1px; left: 3px; width: 12px; height: 7px; border: 1.5px solid; border-radius: 7px 7px 2px 2px; }
.icon-partners::before, .icon-partners::after { width: 8px; height: 8px; border: 1.5px solid; border-radius: 2px; transform: rotate(45deg); }
.icon-partners::before { top: 3px; left: 2px; }
.icon-partners::after { bottom: 3px; right: 1px; }
.icon-settlements::before { inset: 2px 1px; border: 1.5px solid; border-radius: 3px; }
.icon-settlements::after { inset: 6px 4px auto; height: 4px; border-top: 1.5px solid; border-bottom: 1.5px solid; }
.icon-audit::before { inset: 1px 3px; border: 1.5px solid; border-radius: 2px; }
.icon-audit::after { inset: 6px 6px auto; height: 4px; border-top: 1.5px solid; border-bottom: 1.5px solid; }
.sidebar-environment {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: auto 9px 0;
  padding-top: 20px;
  border-top: 1px solid rgb(218 244 218 / 15%);
}
.sidebar-environment i { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); }
.workspace { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 68px;
  padding: 10px clamp(20px, 4vw, 50px);
  border-bottom: 1px solid var(--line);
  background: #f8faf7;
}
.mobile-environment { display: none; }
.account { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 12px;
  background: #e0efdb;
  color: var(--green);
  font-weight: 800;
}
.account-copy { display: grid; min-width: 0; font-size: .875rem; line-height: 1.32; }
.account-copy strong { overflow: hidden; max-width: 180px; text-overflow: ellipsis; white-space: nowrap; }
.account-copy span { color: var(--muted); }
.account .quiet { margin-left: 6px; }
.main { width: min(100%, 1400px); margin-inline: auto; padding: clamp(23px, 3.5vw, 52px); }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-heading h1 { margin-bottom: 5px; font-size: clamp(1.78rem, 3vw, 2.4rem); line-height: 1.2; letter-spacing: -.055em; }
.page-heading h1:focus { outline: none; }
.page-heading p { margin-bottom: 0; color: var(--muted); }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.button {
  min-height: 42px;
  max-width: 100%;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 650;
  font-size: .9rem;
  cursor: pointer;
  white-space: nowrap;
}
.button:disabled { cursor: wait; opacity: .65; }
.primary { background: #cbed62; color: #193523; }
.primary:hover:enabled { background: #dbfb7a; }
.secondary { border-color: #ceded1; background: #fff; color: var(--green); }
.secondary:hover:enabled, .quiet:hover:enabled { background: #eaf3e9; }
.quiet { border-color: transparent; background: transparent; color: var(--green); }
.text-button { padding-inline: 9px; }
.message {
  margin: 0 0 16px;
  padding: 10px 13px;
  border: 1px solid #ead4ce;
  border-radius: 9px;
  background: #fcf1ee;
  color: #823428;
  overflow-wrap: anywhere;
}
.message.success { border-color: #cde4ce; background: #ebf6e9; color: #245439; }

.auth-card form, #create-form, .form-field { display: grid; gap: 8px; }
form label { color: #294c37; font-size: .9rem; font-weight: 700; }
.auth-card input, #create-form > input { margin-bottom: 10px; }
input, select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid #cdded0;
  border-radius: 8px;
  background: #fbfdfb;
}
input:focus, select:focus { border-color: var(--focus); }
select {
  appearance: none;
  padding-right: 31px;
  background-image: linear-gradient(45deg, transparent 50%, #51735a 50%), linear-gradient(135deg, #51735a 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.hint { margin: -9px 0 6px; color: var(--muted); font-size: .875rem; }
.filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 17px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f9fbf8;
}
.filters label { display: grid; gap: 6px; flex: 0 1 220px; }

.data-card {
  min-width: 0;
  min-height: 190px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgb(26 51 38 / 4%);
}
.record-count { padding: 14px 17px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.record-count:empty { display: none; }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 630px; border-collapse: collapse; text-align: left; font-size: .9rem; }
th { background: #f4f8f4; color: #425e4d; font-size: .875rem; font-weight: 700; white-space: nowrap; }
th, td { padding: 12px 15px; border-bottom: 1px solid #eaf0ea; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f9fcf8; }
td.align-number { font-variant-numeric: tabular-nums; white-space: nowrap; }
td code, dd code { color: #456151; font-family: ui-monospace, monospace; font-size: .83rem; overflow-wrap: anywhere; }
.subtext { display: block; color: var(--muted); font-size: .8125rem; }
.status {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef2ef;
  color: #465b50;
  font-size: .8125rem;
  font-weight: 650;
  white-space: nowrap;
}
.status.ok { background: #e4f2dc; color: #2c5639; }
.status.pending { background: #fff1d6; color: #74510f; }
.status.error { background: #f8e6e2; color: #8b392c; }
.blank { padding: 38px 20px; color: var(--muted); text-align: center; }
.blank p { margin: 0; }
.blank .button { margin-top: 13px; }

dialog {
  width: min(500px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  margin: auto;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 80px rgb(10 35 22 / 28%);
}
dialog::backdrop { background: rgb(12 36 24 / 55%); }
.wide-dialog { width: min(800px, calc(100% - 28px)); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 1.23rem; }
#create-form { padding: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 9px; }
.detail-content { padding: 19px 20px; }
.detail-content h3 { margin: 20px 0 7px; font-size: 1rem; }
.detail-content .table-scroll { border: 1px solid var(--line); border-radius: 9px; }
.detail-content table { min-width: 570px; }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.details-grid dt { color: var(--muted); font-size: .875rem; }
.details-grid dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.audit-detail summary { color: var(--green); cursor: pointer; white-space: nowrap; }
.audit-detail pre {
  max-width: 46ch;
  margin: 6px 0 0;
  padding: 7px;
  border-radius: 6px;
  background: #edf4ed;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: .8rem;
}

@media (max-width: 850px) {
  .shell { grid-template-columns: 185px minmax(0, 1fr); }
  .sidebar { padding-inline: 11px; }
  .sidebar-brand { margin-inline: 4px; }
}

@media (max-width: 660px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: 168px 1fr; }
  .auth-brand { padding: 17px 20px; }
  .auth-brand > .brand { font-size: 1.15rem; }
  .auth-brand > .brand .brand-mark { width: 30px; }
  .auth-art { justify-items: end; padding-right: 19px; mask-image: radial-gradient(ellipse at 77% 55%, #000 10%, transparent 72%); }
  .auth-art .brand-mark { width: 118px; }
  .auth-workspace { align-items: start; padding-block: 22px; }
  .shell { display: block; }
  .sidebar { position: static; height: auto; min-height: auto; padding: 12px 13px 6px; }
  .sidebar-brand { margin: 0 0 6px; }
  .sidebar-caption, .sidebar-environment, .nav-icon { display: none; }
  #navigation { display: flex; overflow-x: auto; gap: 4px; padding: 3px 2px 5px; }
  #navigation a { padding: 7px 9px; font-size: .875rem; }
  .topbar { min-height: 54px; justify-content: space-between; padding: 5px 13px; }
  .mobile-environment { display: block; color: var(--muted); font-size: .875rem; white-space: nowrap; }
  .account { gap: 7px; }
  .account-copy strong { max-width: 100px; }
  .account .quiet { min-height: 38px; margin: 0; padding-inline: 7px; }
  .avatar { width: 29px; height: 29px; border-radius: 9px; }
  .main { padding: 22px 13px; }
  .page-heading { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-heading p { max-width: 46ch; }
  .filters label { flex: 1 1 105px; }
  .filters .button { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
