:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #dfe5ef;
  --text: #172033;
  --muted: #6b7688;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: #111827;
  color: #e5edf7;
  padding: 18px 14px;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.brand strong { display: block; font-size: 15px; }
.brand span { color: #94a3b8; font-size: 12px; }
.nav-groups {
  display: grid;
  gap: 8px;
}
.nav-group {
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  padding-top: 8px;
}
.nav-group:first-child {
  border-top: 0;
  padding-top: 0;
}
.nav-group summary {
  list-style: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  padding: 8px 10px;
  border-radius: 6px;
  user-select: none;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::before {
  content: "›";
  display: inline-block;
  width: 14px;
  color: #64748b;
  transform: rotate(0deg);
}
.nav-group[open] summary::before {
  transform: rotate(90deg);
}
.nav-group summary:hover {
  background: #1f2937;
  color: #e5edf7;
}
nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px 9px 28px;
  border-radius: 6px;
  color: #cbd5e1;
  margin: 2px 0;
}
nav a:hover, nav a.active { background: #243044; color: #fff; }
.nav-badge {
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  background: #ef4444;
  color: #fff;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.main { margin-left: 248px; min-height: 100vh; padding: 24px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0 0 6px; font-size: 24px; }
.topbar p { margin: 0; color: var(--muted); }
.userbar { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.userbar a { color: var(--primary); }
.notification-pill {
  display: none;
  align-items: center;
  gap: 6px;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #b42318 !important;
  border-radius: 99px;
  padding: 6px 10px;
  font-weight: 700;
}
.notification-pill.has-alert { display: inline-flex; }
.notification-pill strong {
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  background: #ef4444;
  color: #fff;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  font-size: 11px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.file-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.file-action:hover { border-color: #9aa8bb; }
.file-action input { display: none; }
button, .button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
  min-height: 36px;
}
button:hover, .button:hover { border-color: #9aa8bb; }
button.primary, .primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
button.primary:hover, .primary:hover { background: var(--primary-dark); }
button:disabled, .button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}
button.is-loading {
  position: relative;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}
label { display: block; margin: 12px 0 6px; color: #344054; font-weight: 600; }
textarea { resize: vertical; line-height: 1.5; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head span { color: var(--muted); font-size: 12px; }
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 14px;
  align-items: start;
}
.import-panel { margin-bottom: 14px; }
.import-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}
.import-result {
  min-height: 136px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}
.import-status {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
}
.import-status.is-loading {
  color: #0f766e;
  font-weight: 700;
}
.import-status.is-success {
  color: #027a48;
  font-weight: 700;
}
.import-status.is-error {
  color: var(--danger);
  font-weight: 700;
}
.planner-grid {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 14px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
}
.stat span { display: block; color: var(--muted); margin-bottom: 8px; }
.stat strong { font-size: 24px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.data-table th, .data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table th { color: var(--muted); font-size: 12px; background: #f8fafc; }
.data-table tr { cursor: pointer; }
.data-table tr:hover td { background: #f9fbfd; }
.table-link { color: var(--primary); font-weight: 600; }
.table-panel { overflow-x: auto; }
.editor { position: sticky; top: 16px; }
.searchable-relation {
  display: grid;
  gap: 8px;
}
.searchable-relation .relation-search-input {
  background: #f8fafc;
}
.relation-search-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
}
.screenshot-preview {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.screenshot-preview img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}
.json-box {
  min-height: 520px;
  overflow: auto;
  background: #0b1220;
  color: #d4f7e9;
  border-radius: 8px;
  padding: 14px;
  line-height: 1.5;
}
.planner-document {
  min-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  line-height: 1.6;
}
.planner-doc {
  display: grid;
  gap: 16px;
}
.planner-doc-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.planner-doc-header h3 {
  margin: 4px 0 6px;
  font-size: 20px;
}
.planner-doc-header p {
  margin: 0;
  color: var(--muted);
}
.doc-kicker {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}
.planner-doc section {
  display: grid;
  gap: 10px;
}
.planner-doc h4 {
  margin: 0;
  font-size: 15px;
}
.planner-doc-fields {
  display: grid;
  gap: 8px;
  margin: 0;
}
.planner-doc-fields div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}
.planner-doc-fields dt {
  color: var(--muted);
  font-weight: 600;
}
.planner-doc-fields dd {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.planner-doc ul {
  margin: 0;
  padding-left: 20px;
}
.planner-doc-alert {
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  padding: 12px;
}
.planner-doc-alert strong {
  color: #9a3412;
}
.planner-doc-alert p {
  margin: 4px 0 0;
}
.planner-raw-json {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.planner-raw-json summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
}
.planner-raw-json pre {
  max-height: 320px;
  overflow: auto;
  background: #0b1220;
  color: #d4f7e9;
  border-radius: 8px;
  padding: 12px;
}
.planner-chat {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.planner-chat-history {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px;
}
.planner-chat-msg {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.planner-chat-msg:last-child { border-bottom: 0; }
.planner-chat-msg strong {
  display: block;
  margin-bottom: 4px;
  color: var(--primary);
}
.planner-chat-msg.user strong { color: #344054; }
.planner-chat-msg p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.5;
}
.funnel {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.funnel-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}
.funnel-item strong { display: block; font-size: 22px; margin-top: 6px; }
.chat-history {
  display: grid;
  gap: 8px;
}
.chat-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}
.main-chat {
  grid-template-columns: minmax(0, 1fr) 420px;
}
.profile-box {
  display: grid;
  gap: 8px;
  line-height: 1.6;
}
.profile-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}
.profile-item strong { color: var(--text); }
.suggestions {
  display: grid;
  gap: 8px;
}
.suggestion {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}
.suggestion strong { display: block; margin-bottom: 6px; }
.suggestion p { margin: 0 0 8px; color: #344054; line-height: 1.5; white-space: pre-wrap; }
.reply-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.chat-message {
  max-width: 760px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
}
.chat-message.outbound { margin-left: auto; background: #ecfdf5; }
.chat-message small { display: block; color: var(--muted); margin-bottom: 4px; }
.chat-message p {
  margin: 0;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-translation {
  margin-top: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px dashed #d0d5dd;
  background: rgba(255, 255, 255, 0.72);
}
.chat-translation span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.chat-translation p {
  color: #344054;
  font-size: 13px;
}
.simulator-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr) 380px;
  gap: 14px;
  align-items: start;
}
.simulator-control,
.simulator-analysis-panel {
  position: sticky;
  top: 16px;
}
.sim-chat-history {
  min-height: 620px;
  max-height: calc(100vh - 180px);
  overflow: auto;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.sim-chat-msg {
  max-width: 78%;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}
.sim-chat-msg.ai {
  margin-left: auto;
  background: #ecfdf5;
  border-color: #bbf7d0;
}
.sim-chat-msg small {
  display: block;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 700;
}
.sim-chat-msg p {
  margin: 0;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.sim-translation {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px dashed #d0d5dd;
}
.sim-translation span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.sim-translation p {
  color: #344054;
  font-size: 13px;
}
.sim-analysis-summary {
  display: grid;
  gap: 8px;
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #101828;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  display: none;
  z-index: 10;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef3f8;
}
.login-card {
  width: min(420px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}
.login-brand { color: var(--text); }
.alert {
  background: #fef3f2;
  color: var(--danger);
  border: 1px solid #fecdca;
  border-radius: 6px;
  padding: 9px 10px;
  margin-bottom: 12px;
}
.alert.success {
  background: #ecfdf3;
  color: #027a48;
  border-color: #abefc6;
}
.muted { color: var(--muted); }
.field-help {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.6;
}
.metric-summary {
  display: inline-block;
  max-width: 460px;
  line-height: 1.5;
  white-space: normal;
  color: #344054;
}
.report-toolbar {
  align-items: end;
  gap: 12px;
}
.report-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.daily-report {
  background: #f3f6fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-height: 720px;
}
.report-hero {
  background: #184a86;
  color: #fff;
  padding: 26px 34px;
}
.report-hero h2 {
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 1.2;
  font-weight: 650;
}
.report-hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
}
.report-warning {
  margin: 20px 34px 0;
  padding: 12px 16px;
  background: #fffaeb;
  border: 1px solid #fedf89;
  border-radius: 8px;
  color: #7a4b0f;
  line-height: 1.6;
}
.report-block {
  padding: 0 34px 24px;
}
.report-block h3 {
  margin: 22px 0 12px;
  color: #12355b;
  font-size: 24px;
  font-weight: 600;
}
.report-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}
.report-kpi {
  background: #fff;
  border: 1px solid #d7e2ef;
  border-radius: 8px;
  padding: 14px 16px;
}
.report-kpi span {
  display: block;
  color: #667085;
  font-size: 13px;
  margin-bottom: 8px;
}
.report-kpi strong {
  display: block;
  color: #173b63;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.15;
}
.report-table-wrap {
  overflow-x: auto;
}
.report-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #d7e2ef;
}
.narrow-report-table {
  min-width: 680px;
  max-width: 920px;
}
.report-table th,
.report-table td {
  border: 1px solid #d7e2ef;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  line-height: 1.5;
}
.report-table th {
  background: #e9f1fb;
  color: #344054;
  font-weight: 600;
}
.report-eval {
  display: inline-block;
  min-width: 52px;
  color: #175cd3;
  font-weight: 700;
}
.report-list {
  margin: 0;
  padding-left: 22px;
  line-height: 1.9;
  color: #344054;
}
.report-footer {
  margin-top: 22px;
  padding: 18px 34px;
  background: #184a86;
  color: rgba(255, 255, 255, 0.86);
}

@media (max-width: 1100px) {
  .sidebar { position: static; width: auto; }
  .main { margin-left: 0; }
  .content-grid, .planner-grid, .chat-workbench, .main-chat, .import-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .report-kpis { grid-template-columns: repeat(2, 1fr); }
  .report-hero, .report-block, .report-footer { padding-left: 18px; padding-right: 18px; }
  .report-warning { margin-left: 18px; margin-right: 18px; }
}
