:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --panel: #ffffff;
  --ink: #1e2620;
  --muted: #687166;
  --line: #dfe5dc;
  --accent: #1f7a5b;
  --accent-strong: #175f48;
  --amber: #b46a1f;
  --red: #b83b3b;
  --blue: #316d9f;
  --shadow: 0 18px 50px rgba(30, 38, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

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

a:hover {
  text-decoration: underline;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled,
button:disabled:hover {
  border-color: var(--line);
  background: #eef1ee;
  color: #9aa299;
  cursor: not-allowed;
}

button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

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

button.danger {
  color: var(--red);
}

button.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

input[type="checkbox"] {
  width: auto;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 91, 0.12);
}

textarea {
  resize: vertical;
}

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span,
.operator-card strong,
.operator-card span {
  display: block;
}

.brand span,
.operator-card span,
.eyebrow,
.panel-head span,
.metric-card span,
.metric-card small,
.hint {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  justify-content: flex-start;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav button.active {
  border-color: rgba(31, 122, 91, 0.28);
  background: rgba(31, 122, 91, 0.1);
  color: var(--accent-strong);
  font-weight: 700;
}

.operator-card {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: 30px;
  line-height: 1.15;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.notice {
  margin-bottom: 16px;
  border: 1px solid #c9d8c6;
  border-radius: 8px;
  background: #f7fbf2;
  color: #40563b;
  padding: 12px 14px;
}

.notice.error,
.inline-error {
  border-color: rgba(184, 59, 59, 0.25);
  background: rgba(184, 59, 59, 0.08);
  color: var(--red);
}

.notice.warning {
  border-color: rgba(180, 106, 31, 0.3);
  background: rgba(180, 106, 31, 0.08);
  color: var(--amber);
}

.notice.success {
  color: var(--accent-strong);
}

.export-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.export-result strong,
.export-result span {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

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

.grid.split {
  grid-template-columns: minmax(300px, 0.8fr) minmax(380px, 1.2fr);
}

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

.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.metric-card {
  min-height: 124px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-card strong {
  font-size: 30px;
  line-height: 1.1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  align-items: end;
  gap: 12px;
}

.toolbar.compact {
  grid-template-columns: repeat(2, minmax(120px, 1fr)) auto;
  margin-bottom: 14px;
}

.table-panel .toolbar {
  margin-bottom: 14px;
}

.toolbar .wide {
  grid-column: span 4;
}

.stack-form {
  display: grid;
  gap: 12px;
}

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

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

label.check input {
  width: auto;
}

.bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(140px, 1fr) 72px;
  align-items: center;
  gap: 12px;
}

.bar-row > span {
  overflow-wrap: anywhere;
  color: var(--muted);
}

.bar-row div {
  height: 10px;
  border-radius: 999px;
  background: #edf1ea;
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.rate-line {
  margin: -6px 0 2px 0;
  padding-left: 0;
  color: var(--muted);
  font-size: 12px;
}

.todo-list,
.checklist,
.ticket-list {
  display: grid;
  gap: 10px;
}

.todo-list > div,
.check-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.todo-list span,
.check-item p {
  display: block;
  margin: 5px 0 0;
  color: var(--muted);
}

.todo-list button,
.check-item button {
  margin-top: 10px;
}

.check-item {
  display: flex;
  gap: 10px;
}

.check-item > span {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.ticket-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 4px 10px;
  width: 100%;
  min-height: auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  padding: 12px;
}

.ticket-select-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: flex-start;
}

.ticket-select-row > input {
  margin-top: 15px;
}

.work-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.work-row > .work-main:first-child {
  grid-column: 1 / 3;
}

.work-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.work-main strong,
.work-main span,
.work-main small {
  overflow-wrap: anywhere;
}

.work-main span,
.work-main small {
  color: var(--muted);
}

.work-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.selection-count {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--muted);
  background: #fbfcfa;
  font-size: 13px;
}

.list-tools {
  display: flex;
  justify-content: flex-start;
  margin: 10px 0;
}

.list-tools label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.ticket-row:hover,
.ticket-row.active {
  border-color: var(--accent);
  background: #f6fbf7;
}

.ticket-row strong,
.ticket-row small {
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 56px;
  height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #eef1ee;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pill.open {
  background: rgba(184, 59, 59, 0.1);
  color: var(--red);
}

.pill.admin,
.pill.processing,
.pill.running {
  background: rgba(49, 109, 159, 0.12);
  color: var(--blue);
}

.pill.contributor,
.pill.resolved,
.pill.success,
.pill.delivered {
  background: rgba(31, 122, 91, 0.12);
  color: var(--accent-strong);
}

.pill.create,
.pill.rejected,
.pill.failed {
  background: rgba(184, 59, 59, 0.1);
  color: var(--red);
}

.pill.disputed,
.pill.needs_review {
  background: rgba(180, 106, 31, 0.12);
  color: var(--amber);
}

.pill.approved {
  background: rgba(31, 122, 91, 0.12);
  color: var(--accent-strong);
}

.pill.ok {
  background: rgba(31, 122, 91, 0.12);
  color: var(--accent-strong);
}

.pill.warning {
  background: rgba(180, 106, 31, 0.12);
  color: var(--amber);
}

.pill.critical {
  background: rgba(184, 59, 59, 0.1);
  color: var(--red);
}

.pill.active,
.pill.confirmed,
.pill.restore {
  background: rgba(31, 122, 91, 0.12);
  color: var(--accent-strong);
}

.pill.update {
  background: rgba(49, 109, 159, 0.12);
  color: var(--blue);
}

.pill.archive,
.pill.exhausted,
.pill.family_reported,
.pill.merge,
.pill.owner {
  background: rgba(180, 106, 31, 0.12);
  color: var(--amber);
}

.pill.uncertain,
.pill.viewer {
  background: rgba(104, 113, 102, 0.12);
  color: var(--muted);
}

.pill.revoked,
.pill.skipped,
.pill.expired,
.pill.archived,
.pill.merged {
  background: rgba(104, 113, 102, 0.12);
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.detail-grid span,
.detail-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.detail-grid span {
  color: var(--muted);
  font-size: 13px;
}

.compact-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.compact-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.compact-section .compact-head h3 {
  margin: 0;
}

.compact-section .empty {
  min-height: 72px;
}

.description {
  border-left: 3px solid var(--accent);
  margin: 0 0 14px;
  padding: 10px 12px;
  background: #f7faf5;
  white-space: pre-wrap;
}

.attachment-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.attachment-link {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fbfcfa;
}

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

.result-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.result-card strong,
.result-card span {
  display: block;
}

.empty {
  min-height: 110px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

.json {
  max-height: 420px;
  overflow: auto;
  margin: 0;
  border-radius: 8px;
  background: #1e2620;
  color: #eff5ef;
  padding: 14px;
  font-size: 12px;
  line-height: 1.5;
}

.cell-json {
  max-width: 280px;
  max-height: 120px;
  overflow: auto;
  margin: 0;
  border-radius: 6px;
  background: #f6f8f5;
  color: var(--muted);
  padding: 8px;
  font-size: 12px;
  line-height: 1.45;
}

.config-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.config-sections {
  display: grid;
  gap: 14px;
}

.config-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  overflow: hidden;
}

.config-section h3 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.config-section .table-wrap {
  padding: 0 6px 6px;
}

.table-wrap {
  overflow: auto;
}

.compact-table {
  margin-top: 12px;
  max-height: 320px;
}

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

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

td {
  max-width: 220px;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.pagination div {
  display: flex;
  gap: 8px;
}

.inline-error {
  margin-top: 12px;
  border: 1px solid;
  border-radius: 8px;
  padding: 10px;
}

.hint {
  margin: 12px 0 0;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .metric-grid,
  .grid.two,
  .grid.split {
    grid-template-columns: 1fr;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar.compact {
    grid-template-columns: 1fr;
  }

  .toolbar .wide {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions button {
    flex: 1;
  }

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

  .bar-row,
  .detail-grid,
  .work-row {
    grid-template-columns: 1fr;
  }

  .work-actions {
    justify-content: stretch;
  }

  .work-actions button {
    flex: 1;
  }
}
