
:root {
  --bg: #f3f0e8;
  --ink: #1d2522;
  --muted: #68736f;
  --line: #d9d3c7;
  --panel: #fffdf7;
  --panel-strong: #ebe4d4;
  --green: #176b4d;
  --green-soft: #dff0e6;
  --red: #a73632;
  --red-soft: #f7dfdc;
  --blue: #245d86;
  --blue-soft: #dceaf3;
  --shadow: 0 10px 30px rgba(29, 37, 34, 0.07);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: #f7f8f5;
  color: var(--ink);
  font-family: "Aptos", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
a { color: inherit; }
.shell { max-width: 1440px; margin: 0 auto; padding: 28px; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  margin-bottom: 22px;
}
.brand h1 { margin: 0; font-size: 31px; letter-spacing: 0; }
.brand p { margin: 6px 0 0; color: var(--muted); }
.nav { display: flex; flex-wrap: wrap; gap: 8px; }
.nav a {
  text-decoration: none; padding: 9px 13px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(255, 253, 247, 0.72);
  color: var(--muted); font-weight: 700; font-size: 14px;
}
.nav a.active { background: var(--ink); color: #fffaf0; border-color: var(--ink); }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two { grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr); }
.flat-panel { box-shadow: none; border-radius: 8px; background: rgba(255, 250, 240, 0.5); }
.panel, .stat {
  background: rgba(255, 253, 247, 0.9);
  border: 1px solid rgba(217, 211, 199, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.panel { padding: 18px; overflow: hidden; }
.stat { padding: 18px; position: relative; min-height: 132px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.stat .value { font-size: 42px; line-height: 1; margin-top: 13px; font-weight: 850; letter-spacing: 0; }
.stat .hint { color: var(--muted); margin-top: 12px; font-size: 13px; }
.stat.good { background: linear-gradient(150deg, #fffdf7, var(--green-soft)); }
.stat.bad { background: linear-gradient(150deg, #fffdf7, var(--red-soft)); }
.stat.work { background: linear-gradient(150deg, #fffdf7, var(--blue-soft)); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.section-title a, .pager a, .button {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px;
  text-decoration: none; color: var(--muted); background: #fffaf0; font-weight: 700;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 10px; border-bottom: 1px solid #ebe5da; text-align: left; vertical-align: top; font-size: 13px; }
th { color: var(--muted); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.mono { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 800; }
.pill.good { color: var(--green); background: var(--green-soft); }
.pill.bad { color: var(--red); background: var(--red-soft); }
.pill.work { color: var(--blue); background: var(--blue-soft); }
.pill.quiet { color: var(--muted); background: #eee8dc; }
.progress { min-width: 110px; }
.bar { height: 8px; background: #e7dfd2; border-radius: 999px; overflow: hidden; margin-top: 5px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); }
.filters { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.filters input, .filters select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px;
  background: #fffaf0; color: var(--ink); font: inherit;
}
.filters button { border: 0; border-radius: 12px; background: var(--ink); color: #fffaf0; font-weight: 800; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; color: var(--muted); }
pre {
  margin: 0; padding: 14px; border-radius: 16px; background: #191f1d; color: #f6efe2;
  overflow: auto; max-height: 430px; font-size: 12px; line-height: 1.55;
}
.detail-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 16px; }
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 12px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); font-weight: 800; }
.empty { color: var(--muted); padding: 22px; text-align: center; border: 1px dashed var(--line); border-radius: 16px; }
.url { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.created-token {
  border: 1px solid rgba(23, 107, 77, 0.25);
  background: var(--green-soft);
  border-radius: 16px;
  padding: 13px;
  margin-bottom: 12px;
}
.stack { display: grid; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.strong { font-weight: 900; }
.config-summary {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.config-summary > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  padding: 12px;
  min-height: 72px;
}
.config-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 6px;
}
.config-summary strong { font-size: 28px; }
.config-summary p { margin: 0; color: var(--muted); line-height: 1.55; }
.button, button {
  cursor: pointer;
}
.button,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #fffaf0;
  color: var(--muted);
  font: inherit;
  font-weight: 850;
}
.button:hover,
button:hover {
  border-color: #c9c0b2;
  background: #fff6e5;
}
.button.primary,
button.primary,
.filters button,
.login-form button {
  border-color: var(--ink);
  background: var(--ink);
  color: #fffaf0;
}
.button.danger,
button.danger {
  color: var(--red);
  border-color: rgba(167, 54, 50, 0.28);
  background: var(--red-soft);
}
.import-card textarea {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  background: #fffaf0;
  color: var(--ink);
  font: 12px/1.55 "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}
.file-picker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 250, 240, 0.75);
  color: var(--muted);
  font-weight: 800;
}
.file-picker input { max-width: 210px; }
.component-hint { color: var(--muted); font-size: 13px; margin: 0; }
.tabs { display: grid; gap: 16px; }
.tab-list { display: flex; gap: 8px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.tab-list button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fffaf0;
  color: var(--muted);
  font-weight: 800;
}
.tab-list button[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fffaf0;
}
.tab-panel[hidden] { display: none; }
.modal {
  border: 0;
  width: min(820px, calc(100vw - 32px));
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(29, 37, 34, 0.28);
}
.modal::backdrop { background: rgba(29, 37, 34, 0.44); }
.modal-inner { padding: 22px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  background: #fffaf0;
  color: var(--muted);
  font-weight: 900;
}
.modal-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 0;
}
.form-section-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}
.modal-form .form-section-title:first-of-type {
  padding-top: 0;
  border-top: 0;
}
.modal-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}
.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  margin-bottom: 7px;
}
.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.builder-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.65);
  padding: 12px;
  display: grid;
  gap: 12px;
}
.template-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 12px;
  display: grid;
  gap: 10px;
}
.template-picker .choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.template-picker .choice-grid button {
  min-height: 48px;
  white-space: normal;
  line-height: 1.25;
  text-align: left;
}
.template-picker .choice-grid button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fffaf0;
}
.template-picker label {
  margin: 0;
}
.builder-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.builder-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.builder-row .wide,
.upload-options {
  grid-column: 1 / -1;
}
.relation-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.relation-summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.relation-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.relation-controls select,
.relation-controls button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  padding: 8px 10px;
}
.relation-graph {
  position: relative;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  gap: 14px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(217, 211, 199, 0.82);
  border-radius: 8px;
  background: #f8f6ee;
  overflow: hidden;
}
.relation-channel-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 680px;
  overflow: auto;
  padding-right: 2px;
}
.relation-channel-button {
  width: 100%;
  border: 1px solid rgba(217, 211, 199, 0.95);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  padding: 10px;
  text-align: left;
  display: grid;
  gap: 7px;
}
.relation-channel-button:hover,
.relation-channel-button[aria-pressed="true"] {
  border-color: rgba(36, 93, 134, 0.58);
  background: #eef5f8;
}
.relation-channel-button strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.relation-channel-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
}
.relation-board-head {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(217, 211, 199, 0.82);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.78);
  padding: 12px;
}
.relation-board-head span,
.relation-board-head p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.relation-board-head strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
}
.relation-board-head p {
  margin: 0;
}
.relation-chart {
  min-height: 680px;
  border: 1px solid rgba(217, 211, 199, 0.72);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.62);
}
.relation-inspector {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}
.relation-inspector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.relation-inspector-list {
  display: grid;
  gap: 8px;
  max-height: 480px;
  overflow: auto;
}
.relation-chip {
  border: 1px solid rgba(36, 93, 134, 0.24);
  background: rgba(255, 253, 247, 0.96);
  border-radius: 8px;
  padding: 9px 10px;
}
.relation-chip strong,
.relation-chip span {
  display: block;
  overflow-wrap: anywhere;
}
.relation-chip span {
  color: var(--muted);
  margin-top: 4px;
  font-size: 12px;
}
.relation-chip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}
.relation-action {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  padding: 7px 9px;
}
.relation-action:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.relation-action.danger {
  color: var(--red);
  border-color: rgba(167, 54, 50, 0.28);
  background: var(--red-soft);
}
.relation-action.danger:hover {
  border-color: var(--red);
  color: var(--red);
}
tr.row-focus {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  background: var(--blue-soft);
}
.condition-box {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 10px;
}
.condition-box[hidden] {
  display: none;
}
.condition-head,
.condition-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}
.condition-list {
  display: grid;
  gap: 10px;
}
.advanced-json summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 900;
  margin-bottom: 10px;
}
.modal-form label.wide,
.modal-form .wide { grid-column: 1 / -1; }
.modal-form input,
.modal-form select,
.modal-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fffaf0;
  color: var(--ink);
  font: inherit;
}
.modal-form textarea {
  min-height: 210px;
  resize: vertical;
  font: 12px/1.55 "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}
.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus,
.import-card textarea:focus {
  outline: 2px solid rgba(36, 93, 134, 0.28);
  border-color: var(--blue);
}
.modal-form .switch-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  color: var(--ink);
}
.modal-form .switch-row input {
  width: auto;
  accent-color: var(--green);
}
.model-route-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(180px, 1fr) minmax(120px, 150px) minmax(180px, 1fr);
  width: 100%;
}
.model-route-row input[type="text"],
.model-route-row select {
  min-width: 0;
  width: 100%;
}
.modal-actions {
  justify-content: flex-end;
  padding-top: 4px;
}
.chart-list { display: grid; gap: 12px; }
.chart-row { display: grid; grid-template-columns: minmax(90px, 0.75fr) minmax(120px, 1fr) 54px; gap: 10px; align-items: center; font-size: 13px; }
.chart-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-weight: 800; }
.chart-value { text-align: right; font-weight: 900; }
.chart-track { height: 10px; border-radius: 999px; background: #e7dfd2; overflow: hidden; }
.chart-track span { display: block; height: 100%; border-radius: inherit; }
.chart-track span.good { background: var(--green); }
.chart-track span.work { background: var(--blue); }
.chart-track span.bad { background: var(--red); }
.chart-track span.quiet { background: var(--muted); }
.line-chart { width: 100%; height: 190px; background: #fffaf0; border: 1px solid var(--line); border-radius: 16px; }
.line-chart circle { fill: var(--green); stroke: #fffaf0; stroke-width: 3; }
.chart-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chart-tags span { border: 1px solid var(--line); border-radius: 999px; padding: 5px 8px; color: var(--muted); font-size: 12px; font-weight: 800; }
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  background: rgba(255, 253, 247, 0.94);
  border: 1px solid rgba(217, 211, 199, 0.9);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 26px;
}
.login-card h1 { margin: 4px 0 8px; font-size: 34px; letter-spacing: -0.05em; }
.eyebrow { margin: 0; color: var(--green); font-weight: 900; letter-spacing: .12em; text-transform: uppercase; font-size: 12px; }
.login-form { display: grid; gap: 13px; margin-top: 18px; }
.login-form label { display: grid; gap: 7px; color: var(--muted); font-weight: 800; }
.login-form input {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  background: #fffaf0;
  color: var(--ink);
  font: inherit;
}
.login-form button {
  border: 0;
  border-radius: 14px;
  padding: 12px 13px;
  background: var(--ink);
  color: #fffaf0;
  font-weight: 900;
}
.login-error {
  margin-top: 14px;
  border-radius: 14px;
  background: var(--red-soft);
  color: var(--red);
  padding: 10px 12px;
  font-weight: 800;
}
@media (max-width: 920px) {
  .shell { padding: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .stats, .two, .detail-grid, .filters, .modal-form, .chart-row, .config-summary, .condition-head, .condition-row { grid-template-columns: 1fr; }
  .relation-toolbar { align-items: flex-start; flex-direction: column; }
  .relation-controls { justify-content: flex-start; }
  .relation-graph { grid-template-columns: 1fr; gap: 14px; }
  .relation-channel-list { max-height: 300px; }
  .relation-chart { min-height: 560px; }
  .chart-value { text-align: left; }
}
