:root {
  --bg: #f4f7fa;
  --surface: #fff;
  --text: #243442;
  --muted: #637584;
  --line: #dce5ed;
  --accent: #147cb8;
  --tint: #eaf5fc;
  --warn: #fff4d8;
  --danger: #b0382f;
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 15px
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top)) 20px calc(110px + env(safe-area-inset-bottom))
}

button,
input,
select,
textarea {
  font: inherit
}

button {
  cursor: pointer;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 14px
}

button:disabled {
  opacity: .55;
  cursor: wait
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid #6fbae7;
  outline-offset: 2px
}

h1,
h2,
p {
  margin-top: 0
}

h1 {
  font-size: 27px;
  line-height: 1.35;
  margin-bottom: 10px;
  letter-spacing: -.6px
}

h2 {
  font-size: 23px;
  margin-bottom: 0
}

header,
.dialog-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px
}

.eyebrow {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 5px
}

.icon-button {
  width: 44px;
  font-size: 24px;
  padding: 2px;
  border-color: transparent
}

.connection {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line)
}

#version {
  margin-left: auto
}

.dot {
  width: 7px;
  height: 7px;
  background: #188266;
  border-radius: 50%;
  flex: none
}

.dot.offline {
  background: #b37b16
}

.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px
}

.intro p {
  font-size: 14px;
  color: var(--muted);
  margin: 0
}

.text-button {
  color: var(--accent);
  border: 0;
  background: transparent;
  padding-right: 0
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  margin: 8px 0 16px
}

.search span {
  font-size: 26px;
  color: var(--muted)
}

.search input {
  border: 0;
  background: transparent;
  margin: 0;
  min-width: 0;
  padding: 12px 0
}

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--line);
  border-radius: 9px
}

.segmented button {
  border: 0;
  background: transparent;
  min-height: 36px;
  padding: 5px 13px;
  font-size: 13px
}

.segmented button[aria-pressed=true] {
  background: var(--surface);
  color: var(--accent)
}

.muted {
  color: var(--muted);
  font-size: 12px
}

.categories {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: 20px 0 12px
}

.categories button {
  font-size: 12px;
  min-height: 36px;
  padding: 5px 12px;
  border-radius: 20px;
  background: transparent
}

.categories button[aria-pressed=true] {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface)
}

.rules-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px
}

.rule-card {
  position: relative;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 17px 17px 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0
}

.rule-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center
}

.rule-title {
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere
}

.rule-status {
  font-size: 11px;
  color: #188266;
  white-space: nowrap
}

.rule-status.off {
  color: var(--muted)
}

.rule-meta {
  color: var(--muted);
  font-size: 12px;
  min-height: 20px;
  margin: 8px 0 13px
}

.rule-bottom {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px
}

.rule-score {
  color: var(--text);
  font-size: 20px;
  font-weight: 600
}

.rule-score small {
  font-size: 11px;
  font-weight: 400;
  margin-left: 4px
}

.rule-arrow {
  font-size: 20px;
  color: var(--accent)
}

mark {
  background: #fff1ad;
  color: #493900
}

footer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 760px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 2
}

footer span {
  font-size: 12px;
  color: var(--muted)
}

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

.wide {
  width: 100%;
  margin-top: 16px
}

.gate {
  max-width: 390px;
  margin: 70px auto 0
}

.brand-icon {
  background: var(--tint);
  color: var(--accent);
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  font-size: 28px;
  border-radius: 14px;
  margin-bottom: 22px
}

.gate p {
  color: var(--muted)
}

label {
  display: block;
  font-size: 13px;
  margin-top: 15px
}

input,
select,
textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  margin-top: 7px;
  background: var(--surface);
  color: var(--text)
}

dialog {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  max-width: 540px;
  width: calc(100% - 24px);
  max-height: 92dvh;
  overflow: auto
}

dialog::backdrop {
  background: #152b405e
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-width: 0
}

.two-col>* {
  min-width: 0
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px
}

.switch-row label {
  margin: 0
}

.switch-row input {
  width: 23px;
  height: 23px;
  min-height: 0;
  margin: 0;
  accent-color: var(--accent)
}

details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 20px
}

summary {
  cursor: pointer;
  min-height: 36px;
  font-size: 13px
}

.notice {
  font-size: 12px;
  background: var(--tint);
  padding: 12px;
  border-radius: 8px;
  margin: 16px 0 0
}

.error {
  font-size: 13px;
  color: var(--danger)
}

.secondary-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px
}

.secondary-actions button {
  font-size: 13px
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 50px 0
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 12px 18px;
  border-radius: 10px;
  z-index: 5;
  width: max-content;
  max-width: 90%;
  font-size: 13px
}

dl {
  font-size: 13px
}

dt {
  color: var(--muted);
  margin-top: 14px
}

dd {
  margin: 4px 0;
  overflow-wrap: anywhere
}

code {
  display: block;
  padding: 12px;
  background: var(--tint);
  overflow-wrap: anywhere;
  font-size: 13px
}

.history-row {
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0
}

[hidden] {
  display: none !important
}

@media(max-width:480px) {
  main {
    padding-left: 16px;
    padding-right: 16px
  }

  .rules-list {
    grid-template-columns: 1fr
  }

  .rule-card {
    padding: 16px
  }

  .rule-meta {
    margin-bottom: 8px
  }

  .rule-bottom {
    padding-top: 8px
  }

  .gate {
    margin-top: 45px
  }

  h1 {
    font-size: 25px
  }

  dialog {
    padding: 20px
  }

  .filter-row #count {
    font-size: 11px
  }
}

@media(prefers-color-scheme:dark) {
  :root {
    --bg: #16212b;
    --surface: #20303d;
    --text: #edf4fa;
    --muted: #afbecb;
    --line: #3c4c59;
    --accent: #2388c6;
    --tint: #203e52;
    --warn: #51441d;
    --danger: #ffaaa1;
    color-scheme: dark
  }

  .rule-status {
    color: #7bdbbb
  }

  .dot {
    background: #7bdbbb
  }

  .categories button[aria-pressed=true] {
    color: #16212b
  }
}

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

#publish {
  position: sticky;
  bottom: -20px;
  box-shadow: 0 -8px 0 8px var(--surface);
  margin-bottom: 0
}

#rule-kind {
  font-size: 12px
}

/* R8.4 workbench: Tabler-like navigation and table-first information hierarchy. */
:root {
  --bg: #f5f7fa;
  --surface: #fff;
  --text: #243247;
  --muted: #637083;
  --line: #e2e7ee;
  --accent: #206bc4;
  --tint: #edf4fd;
  font-size: 14px
}

main {
  max-width: none;
  padding: 0
}

.gate {
  padding: 28px;
  margin: 8vh auto;
  max-width: 440px
}

.gate h1 {
  font-size: 26px
}

#workspace {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  min-height: 100vh
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh
}

.workspace-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 38px;
  font-size: 16px
}

.brand-mark {
  background: var(--accent);
  color: white;
  border-radius: 7px;
  width: 32px;
  height: 32px;
  text-align: center;
  font-size: 23px
}

#main-nav {
  display: flex;
  flex-direction: column;
  gap: 8px
}

#main-nav button {
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 12px 18px;
  font-weight: 500
}

#main-nav button[aria-current=page] {
  color: var(--accent);
  background: var(--tint);
  box-shadow: inset 3px 0 var(--accent)
}

.sidebar-bottom {
  margin-top: auto;
  padding: 24px 10px;
  font-size: 13px;
  color: var(--muted)
}

.sidebar-bottom span {
  font-size: 11px
}

.work-content {
  min-width: 0;
  padding: 0 32px 48px
}

.workspace-header {
  min-height: 80px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  padding: 14px 0
}

.workspace-header strong {
  display: block;
  font-size: 17px
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap
}

.header-actions label {
  margin: 0;
  display: flex;
  gap: 8px;
  align-items: center
}

.header-actions select {
  margin: 0;
  width: auto;
  max-width: 250px
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 30px;
  gap: 12px
}

.page-title h1 {
  font-size: 26px;
  letter-spacing: 0;
  margin-bottom: 4px
}

.page-title p {
  margin-bottom: 16px;
  font-size: 13px
}

.connection {
  padding: 0 0 20px;
  border: 0;
  flex-wrap: wrap;
  gap: 8px
}

#version {
  margin-left: 14px
}

#last-updated {
  margin-left: auto
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 4px 0 24px
}

.stats-strip>div {
  padding: 20px 24px;
  border-right: 1px solid var(--line)
}

.stats-strip>div:last-child {
  border: 0
}

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

.stats-strip strong {
  display: block;
  font-size: 30px;
  line-height: 1.5;
  font-weight: 600;
  font-variant-numeric: tabular-nums
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
  min-width: 0
}

.panel h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 18px
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center
}

.panel-heading h2 {
  margin: 0
}

.overview-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 24px
}

.status-bar-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin: 22px 0
}

.status-bar-row span {
  min-width: 55px
}

.status-bar-row progress {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
  height: 9px
}

.status-bar-row strong {
  font-size: 12px;
  min-width: 45px;
  text-align: right
}

#overview-tasks {
  margin: 18px 0;
  color: var(--muted)
}

.table-scroll {
  overflow: auto;
  max-width: 100%;
  padding: 0
}

.panel .table-scroll {
  margin-top: 16px
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  text-align: left
}

th {
  background: var(--bg);
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap
}

td,
th {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line)
}

td {
  max-width: 300px;
  min-width: 90px;
  overflow-wrap: anywhere;
  vertical-align: middle;
  font-variant-numeric: tabular-nums
}

td:nth-child(1) {
  font-weight: 500
}

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

tbody tr:hover {
  background: var(--tint)
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 4px;
  background: var(--tint);
  color: var(--accent);
  white-space: nowrap
}

.badge.good {
  background: #e6f5ed;
  color: #17734a
}

.badge.warning {
  background: #fff3db;
  color: #906214
}

.badge.neutral {
  background: var(--bg);
  color: var(--muted)
}

.toolbar {
  display: flex;
  gap: 16px;
  align-items: end;
  flex-wrap: wrap;
  margin: 0 0 20px
}

.toolbar label {
  margin: 0;
  flex: 1;
  min-width: 150px;
  max-width: 280px
}

.toolbar input,
.toolbar select {
  margin-top: 5px
}

.toolbar button {
  white-space: nowrap
}

.summary-line {
  padding: 14px 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  margin: 0 0 16px;
  color: var(--muted)
}

.table-actions {
  min-width: 220px
}

.table-actions button {
  font-size: 12px;
  min-height: 30px;
  padding: 3px 7px;
  margin: 2px;
  border: 0;
  background: var(--tint);
  color: var(--accent)
}

.pagination {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 24px
}

.pagination span {
  margin-right: auto;
  color: var(--muted)
}

.pagination button {
  min-height: 36px
}

.rules-list {
  grid-template-columns: repeat(auto-fit, minmax(265px, 1fr))
}

.rule-card {
  border-radius: 7px
}

.rules-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  color: var(--muted)
}

.rules-footer span {
  font-size: 12px
}

.rules-list .rule-title {
  font-size: 15px
}

.rule-bottom {
  margin-top: auto
}

.column-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 8px 0
}

.column-row input[type=checkbox] {
  width: 18px;
  min-height: 18px;
  flex: none
}

.column-row input {
  margin: 0;
  min-width: 0
}

.column-row button {
  padding: 4px 8px;
  min-width: 44px;
  white-space: nowrap;
  font-size: 12px
}

#pay-fields input[type=checkbox] {
  display: inline-block;
  width: 20px;
  min-height: 20px;
  margin-left: 12px;
  vertical-align: middle
}

#pay-fields label {
  font-size: 14px
}

dialog {
  border-radius: 10px
}

#toast {
  bottom: 28px
}

.error {
  overflow-wrap: anywhere
}

.muted {
  line-height: 1.6
}

button:disabled {
  cursor: not-allowed
}

@media(max-width:1000px) {
  #workspace {
    grid-template-columns: 175px minmax(0, 1fr)
  }

  .work-content {
    padding: 0 20px 32px
  }

  .sidebar {
    padding: 24px 10px
  }

  .workspace-brand {
    font-size: 13px
  }

  .overview-grid {
    grid-template-columns: 1fr;
    gap: 0
  }

  .stats-strip>div {
    padding: 16px 12px
  }

  .header-actions {
    gap: 8px
  }
}

@media(max-width:680px) {
  #workspace {
    display: block
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line)
  }

  .workspace-brand {
    margin: 0 0 12px;
    font-size: 15px
  }

  .brand-mark {
    width: 26px;
    height: 26px;
    font-size: 19px
  }

  .sidebar-bottom {
    display: none
  }

  #main-nav {
    flex-direction: row;
    overflow: auto;
    gap: 3px
  }

  #main-nav button {
    white-space: nowrap;
    padding: 8px 10px;
    min-height: 40px;
    font-size: 12px
  }

  #main-nav button[aria-current=page] {
    box-shadow: inset 0 -2px var(--accent)
  }

  .work-content {
    padding: 0 14px 28px
  }

  .workspace-header {
    gap: 12px;
    align-items: flex-start
  }

  .header-actions {
    width: 100%
  }

  .header-actions label {
    flex: 1
  }

  .header-actions select {
    max-width: 180px;
    font-size: 12px
  }

  .header-actions button {
    min-height: 36px;
    padding: 5px 9px;
    font-size: 12px
  }

  .page-title {
    padding-top: 22px
  }

  .page-title h1 {
    font-size: 23px
  }

  .page-title button {
    font-size: 12px;
    padding: 7px 10px
  }

  .stats-strip {
    grid-template-columns: repeat(3, 1fr);
    margin-bottom: 16px
  }

  .stats-strip>div {
    padding: 12px
  }

  .stats-strip>div:nth-child(3) {
    border: 0
  }

  .stats-strip strong {
    font-size: 25px
  }

  .stats-strip span {
    font-size: 11px
  }

  .panel {
    padding: 16px;
    margin-bottom: 16px
  }

  .panel.table-scroll {
    padding: 0
  }

  .toolbar {
    gap: 10px
  }

  .toolbar label {
    min-width: 130px;
    max-width: none
  }

  .toolbar button {
    flex: 1;
    font-size: 12px
  }

  .connection {
    font-size: 11px
  }

  #last-updated {
    margin-left: 0
  }

  .summary-line {
    font-size: 12px;
    padding: 12px
  }

  .rules-list {
    grid-template-columns: 1fr
  }

  .rules-footer {
    gap: 10px
  }

  .rules-footer button {
    font-size: 12px
  }

  .pagination {
    font-size: 12px
  }

  .gate {
    margin: 30px auto;
    padding: 24px
  }

  .column-row button {
    padding: 3px 5px
  }

  .column-row input {
    font-size: 12px
  }

  td,
  th {
    padding: 11px 12px
  }
}

@media(prefers-color-scheme:dark) {
  :root {
    --bg: #18222e;
    --surface: #202d3b;
    --text: #eef2f7;
    --muted: #afbdce;
    --line: #3b4959;
    --accent: #70b3ff;
    --tint: #263e58
  }

  .primary,
  .brand-mark {
    color: #132538
  }

  .badge.good {
    background: #173e32;
    color: #8ee0b9
  }

  .badge.warning {
    background: #493a21;
    color: #f0cf8c
  }

  .categories button[aria-pressed=true] {
    color: var(--bg)
  }
}
