:root {
  --ink: #18201c;
  --muted: #68746d;
  --line: #d9dfdb;
  --paper: #f5f7f4;
  --white: #fff;
  --green: #116a45;
  --green-dark: #14281d;
  --green-soft: #e6f2eb;
  --lime: #c9f36a;
  --red: #ae352f;
  --red-soft: #fae7e5;
  --amber: #8d5c00;
  --amber-soft: #faeed2;
  --shadow: 0 18px 50px rgb(20 40 29 / 12%);
}

* { box-sizing: border-box; }
html { min-width: 320px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Noto Sans SC", "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

aside {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 236px;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--green-dark);
  color: #eef5ef;
}

.brand {
  padding: 0 10px 26px;
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 20px;
}

.signal {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  display: inline-block;
  background: var(--lime);
  box-shadow: 0 0 0 5px rgb(201 243 106 / 13%);
}

nav { display: grid; gap: 4px; }

nav button, .account button {
  min-height: 40px;
  border: 0;
  border-radius: 5px;
  padding: 10px 12px;
  background: transparent;
  color: #afbeb4;
  text-align: left;
}

nav button:hover, nav button:focus-visible, nav button.active {
  outline: none;
  background: #263c2f;
  color: #fff;
}

.account {
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid rgb(255 255 255 / 10%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.account span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account button { min-height: auto; padding: 5px; }

body > main {
  width: calc(100% - 236px);
  max-width: 1500px;
  min-height: 100vh;
  margin-left: 236px;
  padding: 30px 38px 50px;
}

header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1 { margin: 3px 0 0; font-size: 27px; line-height: 1.25; }
h2 { margin: 0; font-size: 18px; line-height: 1.35; }
h3 { margin: 0 0 6px; font-size: 15px; }

#eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.primary, .secondary, .danger, .icon-btn, .login-form button {
  min-height: 38px;
  border-radius: 5px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  white-space: nowrap;
}

.primary, .login-form button {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.primary:hover, .login-form button:hover { background: #0d593a; }
.danger { border-color: #e5c5c2; color: var(--red); }
.danger:hover { background: var(--red-soft); }
.secondary:hover, .icon-btn:hover { background: #f0f4f1; }
.icon-btn { width: 40px; padding: 7px; font-size: 20px; line-height: 1; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgb(17 106 69 / 20%);
  outline-offset: 1px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.stat {
  min-height: 106px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
}

.stat b { display: block; font-size: 30px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.bad { border-top: 3px solid var(--red); }
.stat.warn { border-top: 3px solid #c48819; }

.overview-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

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

.section-heading {
  margin-bottom: 13px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.toolbar {
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filters input[type="search"] { min-width: 220px; flex: 1 1 260px; }
.filters select { width: auto; min-width: 130px; }

.filter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.filter-row input[type="search"] { grid-column: span 2; }

.inline-editor {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-editor input { flex: 1 1 260px; }

.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid #e7ebe8; text-align: left; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcf9; }

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafbf9;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

td { max-width: 420px; overflow-wrap: anywhere; }

.badge {
  max-width: 100%;
  display: inline-block;
  border-radius: 3px;
  padding: 3px 7px;
  background: #e8eeea;
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.badge.ok { background: #d9f1e5; color: #0b6842; }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }

.sub {
  max-width: 360px;
  margin-top: 3px;
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.model-list, .model-checks { display: flex; flex-wrap: wrap; gap: 5px; }

.row-actions, .dialog-actions, .form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.row-actions button { min-height: 32px; padding: 5px 9px; }
.dialog-actions { margin-top: 22px; justify-content: flex-end; }
.form-actions { margin-top: 4px; }

#notice { min-height: 0; }
.notice { margin-bottom: 15px; padding: 11px 13px; border-left: 3px solid var(--green); background: var(--white); }
.notice.error { border-color: var(--red); }
.error { color: var(--red); }

.empty, .loading {
  min-height: 150px;
  padding: 34px;
  display: grid;
  place-items: center;
  border: 1px dashed #c8d0cb;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  background: rgb(255 255 255 / 50%);
}

.context-strip {
  margin-bottom: 14px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 3px solid var(--green);
  background: var(--green-soft);
  font-size: 13px;
}

.context-strip span { color: var(--muted); }

dialog {
  width: min(720px, calc(100vw - 30px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 25px;
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgb(20 32 25 / 64%); }
dialog > form:first-child { margin: 0; }

.close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 25px;
}

.form-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.form-grid > label, .login-form label, .token-row {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.form-grid .wide { grid-column: 1 / -1; }
.form-block { padding-top: 5px; }
.narrow { max-width: 580px; }
.narrow-panel { max-width: 680px; }

input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #bdc7c0;
  border-radius: 4px;
  padding: 9px 10px;
  background: var(--white);
  color: var(--ink);
}

textarea { resize: vertical; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }

.check-stack { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.check-stack.horizontal { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); font-size: 13px; }
.check input { width: 16px; height: 16px; flex: 0 0 auto; }

.token-grid { display: grid; gap: 8px; }
.token-row { grid-template-columns: minmax(0, 1fr) 150px; align-items: center; }
.token-row span { overflow-wrap: anywhere; }
.mapping-editor { display: grid; gap: 10px; }
.mapping-editor > button { justify-self: start; }
.mapping-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(120px, 180px) auto;
  gap: 8px;
  align-items: center;
}

.pagination {
  margin-top: 12px;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.pagination select { width: auto; }
.pagination button { min-width: 38px; }

.selection-bar {
  margin-bottom: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #bbd3c3;
  background: #edf7f0;
}

.selection-bar[hidden] { display: none; }
.selection-bar span { color: var(--muted); font-size: 13px; }
.table-check { width: 16px; height: 16px; }
.settings-stack { display: grid; gap: 18px; }
.template-list { display: grid; gap: 8px; }
.template-item { padding: 12px; border: 1px solid var(--line); background: var(--white); }
.template-item header { margin: 0; align-items: flex-start; }
.template-item p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.help-list { margin: 0; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 1.65; }

.json {
  max-height: 55vh;
  margin: 16px 0 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 14px;
  background: #f6f8f6;
  color: #233228;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.login-body {
  min-height: 100vh;
  padding: 20px;
  display: grid;
  place-items: center;
  background: #142019;
}

.login-body > .login-shell {
  width: min(780px, 100%);
  min-height: 450px;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  background: var(--white);
  box-shadow: 0 25px 100px rgb(0 0 0 / 30%);
}

.login-mark {
  padding: 50px 42px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: #22372a;
  color: #fff;
}

.login-mark h1 { margin: 15px 0 2px; font-size: 42px; }
.login-mark p { margin: 5px 0 0; color: #b8c8bd; line-height: 1.6; }

.login-form {
  margin: 0;
  padding: 54px 46px;
  display: grid;
  align-content: center;
  gap: 18px;
}

.login-form h2 { margin-bottom: 9px; }
.login-form button { margin-top: 4px; }
.login-form .error { margin: 0; padding: 9px 11px; background: var(--red-soft); font-size: 13px; }

@media (max-width: 920px) {
  aside {
    position: static;
    width: auto;
    height: auto;
    padding: 12px 14px;
    overflow: visible;
  }

  .brand { padding: 3px 6px 12px; }
  nav { display: flex; overflow-x: auto; padding-bottom: 3px; }
  nav button { flex: 0 0 auto; white-space: nowrap; }
  .account { display: none; }

  body > main {
    width: 100%;
    min-height: auto;
    margin: 0;
    padding: 22px 18px 38px;
  }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .login-body { padding: 14px; }
  .login-body > .login-shell { min-height: auto; grid-template-columns: 1fr; }
  .login-mark { min-height: 150px; padding: 26px; }
  .login-mark h1 { font-size: 31px; }
  .login-form { padding: 32px 25px; }

  body > main { padding: 18px 13px 32px; }
  header { margin-bottom: 18px; }
  h1 { font-size: 24px; }
  .stats { gap: 8px; }
  .stat { min-height: 92px; padding: 14px; }
  .stat b { font-size: 25px; }
  .panel { padding: 13px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .token-row { grid-template-columns: 1fr; }
  .mapping-row { grid-template-columns: minmax(0, 1fr) 110px; }
  .mapping-row button { grid-column: 1 / -1; justify-self: start; }
  .context-strip { align-items: flex-start; flex-direction: column; gap: 3px; }
  dialog { padding: 22px 18px; }
  th, td { padding: 9px 10px; }
  .filter-row { grid-template-columns: 1fr; }
  .filter-row input[type="search"] { grid-column: auto; }
  .pagination { justify-content: space-between; flex-wrap: wrap; }
  .selection-bar { align-items: flex-start; flex-direction: column; }
}
