:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --topbar: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-deep: #eef2f7;
  --text: #172033;
  --muted: #667085;
  --muted-2: #8a94a6;
  --line: #dde4ef;
  --primary: #3b82f6;
  --primary-soft: #e8f1ff;
  --primary-deep: #dceaff;
  --accent: #ea580c;
  --success: #22c55e;
  --warn: #b7791f;
  --danger: #b42318;
  --shadow: 0 24px 60px rgba(31, 41, 55, 0.08);
  --button-bg: #ffffff;
  --button-border: #d8e0ea;
  --button-text: #172033;
  --button-hover-text: #0f172a;
  --input-bg: #ffffff;
  --input-border: #d8e0ea;
  --placeholder: #98a2b3;
  --topbar-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
  --runtime-bg: #f8fafc;
  --runtime-border: #dde4ef;
  --runtime-text: #475467;
  --card-border: #e3e8f1;
  --hero-title: #1d4ed8;
  --hero-text: #475569;
  --nav-bg: #ffffff;
  --nav-border: #dde4ef;
  --nav-text: #667085;
  --warning-bg: #fff7ed;
  --warning-border: #fed7aa;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --profile-bg: #ffffff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214;
  --topbar: #222222;
  --surface: #202124;
  --surface-soft: #2f3033;
  --surface-deep: #18191b;
  --text: #f2f4f7;
  --muted: #a1a1aa;
  --muted-2: #71717a;
  --line: #34363a;
  --primary: #3b82f6;
  --primary-soft: #1e365c;
  --primary-deep: #1b3155;
  --accent: #f97316;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #fb7185;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  --button-bg: #3a3a3d;
  --button-border: #3a3a3d;
  --button-text: #e5e7eb;
  --button-hover-text: #ffffff;
  --input-bg: #37373a;
  --input-border: #3f4044;
  --placeholder: #8a8d94;
  --topbar-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
  --runtime-bg: #17181a;
  --runtime-border: #303236;
  --runtime-text: #c7cbd1;
  --card-border: #27282c;
  --hero-title: #3b82f6;
  --hero-text: #b7c5dd;
  --nav-bg: #222222;
  --nav-border: #2e3034;
  --nav-text: #9ca3af;
  --warning-bg: #211a10;
  --warning-border: #7c4a1b;
  --link: #60a5fa;
  --link-hover: #93c5fd;
  --profile-bg: #1b1d21;
}

* {
  box-sizing: border-box;
}

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

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

button,
.button-link {
  align-items: center;
  background: var(--button-bg);
  border: 1px solid var(--button-border);
  border-radius: 7px;
  color: var(--button-text);
  cursor: pointer;
  display: inline-flex;
  font-weight: 650;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  text-decoration: none;
}

button:hover,
.button-link:hover {
  border-color: var(--primary);
  color: var(--button-hover-text);
}

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

button.primary:hover {
  background: #2563eb;
}

button.secondary {
  background: transparent;
  border-color: var(--button-border);
  color: var(--button-text);
}

input,
select,
textarea {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 7px;
  color: var(--text);
  outline: none;
  padding: 13px 15px;
  width: 100%;
}

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

textarea {
  min-height: 168px;
  resize: vertical;
}

#productIntro,
#productNote {
  min-height: 96px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.shell {
  margin: 0 auto;
  max-width: 1420px;
  min-height: 100vh;
  padding: 0 22px 102px;
}

.topbar {
  align-items: center;
  background: var(--topbar);
  box-shadow: var(--topbar-shadow);
  color: var(--text);
  display: flex;
  justify-content: space-between;
  margin: 0 -22px;
  padding: 18px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.brand-icon {
  font-size: 28px;
  line-height: 1;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.topbar h1 {
  font-size: 22px;
  line-height: 1.2;
}

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

.theme-toggle {
  background: var(--runtime-bg);
  border-color: var(--runtime-border);
  border-radius: 999px;
  color: var(--runtime-text);
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
}

.user-box {
  align-items: center;
  background: var(--runtime-bg);
  border: 1px solid var(--runtime-border);
  border-radius: 999px;
  color: var(--runtime-text);
  display: flex;
  font-size: 13px;
  gap: 8px;
  min-height: 34px;
  padding: 0 6px 0 12px;
}

.user-box button {
  border-radius: 999px;
  font-size: 12px;
  min-height: 26px;
  padding: 0 10px;
}

.runtime {
  align-items: center;
  background: var(--runtime-bg);
  border: 1px solid var(--runtime-border);
  border-radius: 999px;
  color: var(--runtime-text);
  display: flex;
  font-size: 13px;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
}

#statusDot {
  background: #7dd3c7;
  border-radius: 50%;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.workspace {
  margin-top: 32px;
}

.view {
  background: transparent;
  border: 0;
  display: none;
  min-height: 680px;
}

.view.active {
  display: block;
}

.section-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.section-head h2 {
  font-size: 24px;
  line-height: 1.25;
}

.section-head p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-top: 5px;
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1.4fr 1fr 1fr;
}

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

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

.textarea-field {
  display: block;
  margin-top: 14px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.output {
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  margin: 32px 0 0;
  min-height: 360px;
  overflow: visible;
  padding: 0;
  white-space: normal;
}

.report {
  display: grid;
  gap: 16px;
}

.report h3 {
  color: var(--text);
  font-size: 18px;
  line-height: 1.4;
  margin: 18px 0 0;
}

.report h3:first-of-type {
  margin-top: 8px;
}

.report h4 {
  color: var(--text);
  font-size: 16px;
  margin: 4px 0 0;
}

.report p,
.report li {
  word-break: break-word;
}

.report p {
  margin: 0;
}

.field-line {
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 132px minmax(0, 1fr);
  line-height: 1.65;
  margin-top: 8px !important;
  padding: 11px 14px;
}

.field-line strong {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.field-line span {
  color: var(--text);
  font-size: 14px;
}

.report-hero {
  background: var(--primary-deep);
  border-left: 4px solid var(--primary);
  border-radius: 0 16px 16px 0;
  padding: 24px 26px;
}

.report-hero h3 {
  background: transparent;
  border: 0;
  color: var(--hero-title);
  font-size: 20px;
  font-weight: 850;
  margin: 0 0 10px;
  padding: 0;
}

.report-hero p {
  color: var(--hero-text);
  line-height: 1.65;
}

.report ul {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.report li {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  color: var(--text);
  padding: 12px 14px;
}

.intel-list li {
  display: grid;
  gap: 5px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.intel-title {
  color: var(--link);
  font-size: 15px;
  font-weight: 780;
  line-height: 1.45;
  text-decoration: none;
}

.intel-title:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.intel-date {
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.6;
  padding-left: 12px;
  white-space: nowrap;
}

.intel-summary {
  color: var(--muted);
  font-size: 14px;
  grid-column: 1 / -1;
  line-height: 1.55;
}

.plain-list {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  gap: 0;
  padding: 12px 16px;
}

.plain-list li {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 6px 0;
}

.intel-list .profile-card {
  background: var(--profile-bg);
  display: block;
}

.intel-list .profile-card p {
  font-size: 15px;
  line-height: 1.85;
  max-width: none;
}

.intel-list .profile-card p + p {
  margin-top: 10px;
}

.profile-meta {
  align-items: center;
  color: var(--muted-2);
  display: flex;
  font-size: 12px;
  gap: 12px;
  margin-top: 8px;
}

.profile-source {
  color: var(--link);
  text-decoration: none;
}

.profile-source:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.loading,
.error {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}

.loading {
  color: var(--warn);
}

.error {
  color: var(--danger);
}

.todo-confirm {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: 10px;
  margin-top: 18px;
  padding: 16px;
}

.todo-confirm h3 {
  font-size: 16px;
}

.todo-confirm p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.detected-item,
.todo-item {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 190px 120px;
  margin-top: 12px;
  padding: 14px;
}

.detected-item strong,
.todo-item strong {
  color: var(--text);
  display: block;
  font-size: 15px;
  line-height: 1.45;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 4px;
}

.todo-form {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1.4fr) 220px minmax(0, 1fr) 90px;
}

.tool-panel {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px;
}

.product-answer {
  min-height: 120px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  margin-top: 18px;
  overflow-x: auto;
}

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

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--card-border);
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.data-table td {
  color: var(--text);
  font-size: 14px;
}

.data-table td:nth-child(3) {
  min-width: 340px;
  white-space: normal;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.empty-cell {
  color: var(--muted) !important;
  text-align: center !important;
}

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

.table-actions button {
  min-height: 32px;
  padding: 0 12px;
}

.file-link {
  color: var(--link);
  font-weight: 800;
  text-decoration: none;
}

.file-link:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.file-meta,
.muted-text,
.file-more {
  color: var(--muted);
  font-size: 12px;
}

.file-list-mini {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.file-row-mini {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.file-row-mini button {
  border-radius: 999px;
  font-size: 12px;
  min-height: 26px;
  padding: 0 9px;
}

.pager {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.pager button {
  min-height: 34px;
  padding: 0 12px;
}

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

.modal-panel.wide {
  max-width: 640px;
  width: min(100%, 640px);
}

.modal-form {
  display: grid;
  gap: 14px;
}

.attachment-block {
  background: var(--surface-soft);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 14px;
}

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

.upload-button {
  min-height: 34px;
  position: relative;
}

.upload-button input {
  display: none;
}

.attachment-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.attachment-item {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px 12px;
}

.attachment-item.pending {
  border-style: dashed;
}

.attachment-item a {
  color: var(--link);
  font-weight: 700;
  text-decoration: none;
}

.attachment-item a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.attachment-item button {
  min-height: 32px;
  padding: 0 12px;
}

.segmented {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  display: inline-grid;
  gap: 4px;
  grid-template-columns: repeat(2, 1fr);
  margin-top: 14px;
  padding: 4px;
}

.segmented button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  min-height: 34px;
  padding: 0 14px;
}

.segmented button.active {
  background: var(--primary);
  color: #fff;
}

.todo-list {
  margin-top: 16px;
}

.todo-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.todo-actions button {
  min-height: 34px;
}

.done {
  opacity: 0.62;
}

.hidden {
  display: none;
}

.modal {
  align-items: center;
  background: rgba(2, 6, 23, 0.58);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 28px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 72px);
  max-width: 520px;
  overflow-y: auto;
  padding: 20px;
  width: min(100%, 520px);
}

.modal-panel h3 {
  font-size: 18px;
}

.modal-panel p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

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

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.bottom-nav {
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border);
  bottom: 0;
  box-shadow: 0 -16px 36px rgba(0, 0, 0, 0.32);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  left: 0;
  position: fixed;
  right: 0;
  z-index: 20;
}

.bottom-nav button {
  background: transparent;
  border: 0;
  border-top: 3px solid transparent;
  border-radius: 0;
  color: var(--nav-text);
  display: grid;
  font-size: 13px;
  gap: 5px;
  min-height: 72px;
  padding: 8px 6px;
}

.bottom-nav button span {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav button.active {
  border-top-color: var(--primary);
  color: var(--primary);
  font-weight: 800;
}

@media (max-width: 860px) {
  .shell {
    padding: 0 12px 92px;
  }

  .topbar {
    margin: 0 -12px;
    padding: 16px 18px;
  }

  .section-head,
  .form-grid,
  .form-grid.two,
  .todo-form,
  .detected-item,
  .todo-item,
  .field-line {
    display: block;
  }

  .workspace {
    margin-top: 26px;
  }

  .top-actions {
    gap: 8px;
  }

  .runtime {
    display: none;
  }

  .section-head button,
  .section-head .button-link {
    margin-top: 12px;
  }

  label + label,
  .todo-form input,
  .todo-form button {
    margin-top: 10px;
  }

  .todo-actions {
    flex-direction: row;
    margin-top: 10px;
  }

  .report-hero {
    border-radius: 0 14px 14px 0;
    padding: 20px;
  }
}
