:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-soft: #fafafa;
  --line: #d9dde3;
  --line-strong: #c2c8d0;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #e8efff;
  --danger: #d14343;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-panel {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 600;
}

.login-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.field {
  margin-bottom: 14px;
}

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

.field input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 12px;
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.btn:disabled {
  cursor: default;
  opacity: 0.6;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-ghost {
  background: #fff;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-small {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.demo-user-actions {
  min-width: 300px;
}

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

.table-inline-form input {
  width: 150px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
}

.error-text {
  color: #b91c1c;
}

.page {
  height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #eef1f5;
  padding: 16px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  margin: 0 16px 20px;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.nav-label {
  margin: 0 16px 8px;
  font-size: 12px;
  color: var(--muted);
}

.nav-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 9px 16px 9px 18px;
  margin-bottom: 0;
  cursor: pointer;
  color: var(--text);
}

.nav-item.active {
  border-left-color: var(--primary);
  background: #e8edf5;
  color: #1748b5;
}

.nav-item + .nav-item {
  margin-top: 2px;
}

.nav-item:hover {
  background: #e9edf3;
}

.nav-group {
  margin: 2px 0;
}

.nav-group-title {
  display: block;
  padding: 10px 16px 6px 18px;
  font-size: 13px;
  font-weight: 700;
  color: #506070;
  cursor: pointer;
  user-select: none;
}

.nav-group-title::marker {
  color: #7b8794;
}

.nav-group-title.active {
  color: #1748b5;
}

.nav-subitem {
  padding-left: 34px;
  font-size: 13px;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100vh;
}

.topbar {
  height: 56px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
}

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

.topbar-user {
  font-size: 13px;
  color: var(--muted);
}

.content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px;
}

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  font-size: 16px;
  font-weight: 600;
}

.section-desc {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.section-subtitle {
  padding: 16px 16px 0;
  font-size: 14px;
  font-weight: 600;
}

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

.platform-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-soft);
}

.platform-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.platform-title {
  font-size: 15px;
  font-weight: 600;
}

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

.platform-body {
  padding: 14px;
}

.field-inline {
  margin-bottom: 14px;
}

.field-inline:last-child {
  margin-bottom: 0;
}

.field-inline label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.field-inline input,
.field-inline select,
.field-inline textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
}

.field-inline input,
.field-inline select {
  height: 36px;
  padding: 0 10px;
}

.field-inline textarea {
  min-height: 260px;
  resize: vertical;
  padding: 10px;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.legal-doc-list {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.legal-doc-card {
  background: #fff;
}

.readonly-text {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

.form-strip {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(180px, 280px) auto;
  align-items: end;
  gap: 12px;
}

.inline-form .field-inline {
  margin-bottom: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  height: 36px;
}

.platform-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 14px 14px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  font-size: 13px;
  color: var(--text);
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.home-frame-create-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr)) auto;
  align-items: end;
  gap: 12px;
}

.home-frame-create-form .field-inline {
  margin-bottom: 0;
}

.home-frame-list {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.home-frame-card {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  overflow: hidden;
  background: #fff;
}

.home-frame-preview {
  position: relative;
  min-height: 300px;
  overflow: hidden;
  background: linear-gradient(135deg, #eef3ff, #fce7f3);
}

.home-frame-preview img,
.home-frame-preview-fallback {
  width: 100%;
  height: 100%;
  min-height: 300px;
  object-fit: cover;
  display: block;
}

.home-frame-preview-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}

.home-frame-preview-copy {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 18px;
  color: #111827;
  font-size: 19px;
  line-height: 1.35;
  font-weight: 700;
  text-shadow: 0 1px 12px rgba(255,255,255,0.72);
}

.home-frame-fields {
  padding: 14px;
}

.home-frame-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.home-frame-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.home-frame-form-grid .field-inline {
  margin-bottom: 0;
}

.home-frame-upload-field {
  grid-column: 1 / -1;
}

.upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.upload-row input[type="file"] {
  height: auto;
  padding: 7px 10px;
}

.upload-status {
  min-height: 18px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.home-frame-actions {
  gap: 8px;
  padding: 14px 0 0;
}

.hint {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  color: var(--muted);
}

.message {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 13px;
}

.message.error {
  background: #fff3f3;
  border-color: #efc0c0;
  color: var(--danger);
}

.message.success {
  background: #eefbf3;
  border-color: #b8e3c4;
  color: #216b3b;
}

.hidden-note {
  margin: 16px 16px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fcfcfd;
}

.filter-item label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.filter-item.wide {
  grid-column: span 3;
}

.filter-item input,
.filter-item select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 10px;
  background: #fff;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.prompt-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 16px;
  padding: 16px;
}

.prompt-version-list {
  display: grid;
  gap: 14px;
}

.prompt-strategy-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background: #fff;
}

.prompt-strategy-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.prompt-strategy-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
}

.prompt-strategy-card textarea {
  min-height: 300px;
}

.prompt-side {
  border-left: 1px solid var(--line);
  padding-left: 16px;
}

.prompt-create-form {
  margin-top: 16px;
}

.prompt-create-form textarea {
  min-height: 180px;
}

.experiment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.experiment-column {
  display: grid;
  align-content: start;
  gap: 16px;
}

.experiment-form {
  padding: 14px;
}

.experiment-form .field-inline textarea {
  min-height: 150px;
}

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

.experiment-form-grid .field-inline {
  margin-bottom: 14px;
}

.experiment-form-actions {
  padding: 0;
  gap: 8px;
}

.experiment-mini-table .data-table {
  min-width: 720px;
}

.experiment-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.experiment-topup {
  display: flex;
  align-items: center;
  gap: 8px;
}

.experiment-topup input {
  width: 84px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 10px;
}

.experiment-sample-list {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.experiment-sample-card {
  background: #fff;
}

.experiment-sample-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.experiment-json,
.experiment-output {
  max-height: 220px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafc;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.experiment-attempt-table {
  min-width: 1120px;
}

.compact-hint {
  margin: 12px 0 0;
}

.table-shell {
  padding: 0 16px 16px;
}

.table-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
}

.table-summary-text {
  font-size: 13px;
  color: var(--muted);
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.data-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.data-table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: top;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #f7f8fa;
  z-index: 1;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.data-table tbody tr:hover {
  background: #fafcff;
}

.data-table input,
.data-table select {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
}

.llm-model-table {
  min-width: 1060px;
}

.nami-insight-message-cell {
  min-width: 260px;
  max-width: 420px;
}

.remote-post-image {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  background: #eceff3;
}

.connection-table {
  min-width: 1380px;
}

.connection-table col.connection-col-meta {
  width: 170px;
}

.connection-table col.connection-col-side {
  width: 360px;
}

.connection-table col.connection-col-lighting {
  width: 210px;
}

.connection-table col.connection-col-count {
  width: 72px;
}

.connection-table col.connection-col-status {
  width: 110px;
}

.connection-table col.connection-col-action {
  width: 92px;
}

.connection-side-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.connection-side-image-btn {
  flex: 0 0 auto;
}

.connection-side-image {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  background: #eceff3;
}

.connection-side-content {
  min-width: 0;
}

.connection-post-body {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  overflow: hidden;
}

.match-simulator-filter {
  grid-template-columns: minmax(280px, 2fr) minmax(220px, 1fr) auto;
}

.match-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.match-stage-section {
  margin-top: 16px;
}

.match-source-card {
  margin-top: 16px;
  background: #fff;
}

.match-source-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.match-source-text {
  margin-top: 10px;
}

.match-source-joint {
  max-height: 132px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.match-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.match-summary-item {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.match-route-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.match-route-detail {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  overflow: hidden;
}

.match-route-detail summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  background: #f8fafc;
}

.match-route-detail .data-table-wrap {
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}

.match-simulator-table {
  min-width: 1280px;
}

.match-post-body {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

.image-preview-btn {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

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

.cell-primary {
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.cell-warning {
  color: #9a6700;
}

.cell-secondary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stack-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  line-height: 1.5;
}

.stack-line:last-child {
  margin-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.link-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid #c6d4f6;
  border-radius: 999px;
  background: #f4f7ff;
  color: #1748b5;
  font-size: 12px;
  cursor: pointer;
}

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

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

.pagination-actions {
  display: flex;
  gap: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal-panel {
  width: min(920px, 100%);
  max-height: min(86vh, 960px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
}

.modal-content {
  max-height: calc(86vh - 64px);
  overflow: auto;
  padding: 16px;
}

.modal-loading,
.modal-empty {
  color: var(--muted);
  font-size: 13px;
}

.image-modal-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-image {
  max-width: 100%;
  max-height: calc(86vh - 120px);
  border-radius: 8px;
  display: block;
}

.modal-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 12px;
}

.modal-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-item-title {
  font-size: 14px;
  font-weight: 600;
}

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

.modal-item-body {
  margin-top: 8px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-item-subtle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-thumb {
  margin-top: 8px;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  background: #eceff3;
}

.modal-thumb-button {
  display: inline-flex;
  margin-top: 8px;
}

.modal-item-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.overlay-backdrop {
  z-index: 70;
  background: rgba(15, 23, 42, 0.56);
}

.overlay-panel {
  width: min(840px, 100%);
}

@media (max-width: 980px) {
  .page {
    height: auto;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .sidebar {
    position: static;
    top: auto;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .main {
    height: auto;
    min-height: 0;
  }

  .content {
    overflow: visible;
  }

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

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .prompt-layout {
    grid-template-columns: 1fr;
  }

  .experiment-layout,
  .experiment-form-grid {
    grid-template-columns: 1fr;
  }

  .experiment-toolbar,
  .experiment-topup {
    flex-direction: column;
    align-items: stretch;
  }

  .prompt-side {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 16px;
  }

  .prompt-strategy-header {
    flex-direction: column;
  }

  .prompt-strategy-grid {
    grid-template-columns: 1fr;
  }

  .table-summary,
  .pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-backdrop {
    padding: 12px;
  }
}
