:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f0f3f7;
  --line: #d9dee8;
  --line-strong: #b8c1cf;
  --text: #172033;
  --muted: #627086;
  --subtle: #7a8798;
  --primary: #2656d9;
  --primary-soft: #e9eefc;
  --success: #16794f;
  --warning: #9a6700;
  --danger: #bd2c2c;
  --radius: 8px;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
}

.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 16px;
}

.hero > div:first-child {
  display: grid;
  gap: 10px;
}

.hero h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.hero p {
  margin: 0;
  max-width: 920px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.tag-row,
.toolbar,
.stats-grid,
.panel-grid,
.pill-group,
.actions,
.cell-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.pill {
  background: var(--primary-soft);
  border-color: #cbd7fb;
  color: #2447a8;
}

button {
  min-height: 36px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

button.is-ghost,
.nav button,
.modal-close {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}

.toolbar {
  align-items: center;
  padding-top: 2px;
}

.token-bar {
  margin-left: auto;
  display: grid;
  grid-template-columns: minmax(220px, 320px) auto;
  gap: 8px;
  align-items: center;
}

input,
textarea,
select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.notice {
  margin-top: 12px;
  border: 1px solid #cbd7fb;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: #2447a8;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.notice.is-success {
  border-color: #b9decf;
  background: #e8f6ef;
  color: var(--success);
}

.notice.is-error {
  border-color: #f0b8b8;
  background: #fff0f0;
  color: var(--danger);
}

.notice[hidden] {
  display: none;
}

.stat-card,
.summary-card {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.stat-card strong,
.summary-card strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.panel,
.detail-panel,
.log-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel {
  position: sticky;
  top: 12px;
}

.panel h2,
.detail-panel h2,
.log-panel h2 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

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

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

.nav {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.nav button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.nav button.is-active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.section-title {
  margin: 12px 2px 2px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 800;
}

.row-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  display: grid;
  gap: 8px;
  text-align: left;
}

.row-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  filter: none;
}

.row-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.row-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.metrics span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  padding: 4px 8px;
}

.detail-panel {
  min-height: 560px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.editor,
.bank-block {
  display: grid;
  gap: 12px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.summary-card {
  display: grid;
  gap: 4px;
}

.summary-card span {
  color: var(--subtle);
  font-size: 12px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.user-filter-grid {
  grid-template-columns: minmax(220px, 1.5fr) minmax(180px, 1fr) minmax(180px, 1fr);
}

.user-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.user-meta-grid div {
  display: grid;
  gap: 4px;
}

.user-meta-grid span,
.section-heading span {
  color: var(--subtle);
  font-size: 12px;
}

.data-section {
  display: grid;
  gap: 10px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h3 {
  margin: 0;
}

.compact-table {
  min-width: 780px;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-tag.is-success {
  border-color: #a7d9c1;
  background: #ecf8f1;
  color: var(--success);
}

.status-tag.is-warning {
  border-color: #ead3a5;
  background: #fff8e7;
  color: var(--warning);
}

.status-tag.is-muted {
  background: var(--surface-muted);
  color: var(--muted);
}

.timeline {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.timeline-item {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-item span {
  color: var(--muted);
}

.callout {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.import-preview {
  background: var(--surface);
}

.import-preview.is-ready {
  border-color: #a7d9c1;
}

.import-preview.is-blocked {
  border-color: #ead3a5;
}

.import-message-list {
  margin: 0;
  padding-left: 20px;
  color: var(--warning);
  font-size: 13px;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: none;
}

td .field {
  min-width: 120px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(23, 32, 51, 0.34);
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-card {
  width: min(1400px, 100%);
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.modal-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.modal-header p {
  margin: 6px 0 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.modal-close {
  flex-shrink: 0;
}

.modal-body {
  padding: 18px;
  overflow: auto;
  display: grid;
  gap: 14px;
  align-content: start;
}

body.modal-open {
  overflow: hidden;
}

pre {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f172a;
  color: #dbeafe;
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
}

.raw-details {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 10px 12px;
}

.raw-details summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-muted);
}

.log-panel {
  margin-top: 16px;
}

@media (max-width: 980px) {
  .page {
    padding: 12px;
  }

  .toolbar,
  .token-bar {
    width: 100%;
  }

  .token-bar,
  .panel-grid,
  .editor-grid,
  .filter-grid,
  .user-filter-grid,
  .user-meta-grid {
    grid-template-columns: 1fr;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .panel {
    position: static;
  }

  table {
    min-width: 760px;
  }
}
