:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #172033;
  --muted: #667085;
  --primary: #176b87;
  --primary-strong: #0f536b;
  --accent: #8a5a12;
  --danger: #b42318;
  --ok: #0d7a48;
  --shadow: 0 10px 24px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

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

h1 {
  font-size: 20px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 14px;
  color: var(--text);
}

.topbar p,
.muted {
  color: var(--muted);
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.status-dot {
  min-width: 72px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #f9fafb;
  text-align: center;
}

.status-dot.ok {
  color: var(--ok);
  border-color: rgba(13, 122, 72, 0.24);
  background: #edfcf2;
}

.status-dot.fail {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.25);
  background: #fff1f0;
}

.doc-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(520px, 1fr) minmax(300px, 420px);
  gap: 14px;
  padding: 14px;
  height: calc(100vh - 76px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 0;
}

.sidebar,
.output {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-head {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 12px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fbfcfe;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.list-block {
  padding: 8px 12px 12px;
  min-height: 0;
}

.item-list {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  max-height: 28vh;
  overflow: auto;
  padding-right: 4px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #ffffff;
  cursor: pointer;
}

.item:hover {
  border-color: var(--primary);
}

.item-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.item-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.tab,
.btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.btn {
  padding: 6px 12px;
}

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

.btn.primary:hover {
  background: var(--primary-strong);
}

.btn.ghost {
  background: #f9fafb;
  color: var(--primary);
}

.tab-panel {
  display: none;
  overflow: auto;
  min-height: 0;
}

.tab-panel.active {
  display: block;
}

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

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

.tool {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

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

.upload-block {
  display: grid;
  gap: 10px;
  margin: 12px 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.upload-fields {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) minmax(160px, auto);
  gap: 12px;
  align-items: end;
}

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

.material-status-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #ffffff;
  overflow-wrap: anywhere;
}

.material-status-card.ready {
  border-color: rgba(13, 122, 72, 0.28);
  background: #f4fbf7;
}

.material-status-card.missing {
  border-color: rgba(180, 35, 24, 0.2);
  background: #fff8f7;
}

.material-status-card strong {
  display: block;
}

.material-status-card span {
  color: var(--muted);
  font-size: 12px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.checkline input {
  width: auto;
  min-height: auto;
}

.job-card {
  min-height: 96px;
  display: grid;
  align-content: start;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.job-card:hover {
  border-color: var(--primary);
}

.job-card strong {
  color: var(--text);
  font-size: 15px;
}

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

.export-block {
  padding: 0 12px 12px;
}

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

.export-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #ffffff;
  overflow-wrap: anywhere;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
}

textarea {
  resize: vertical;
  min-height: 76px;
  font-family: Consolas, "Microsoft YaHei", monospace;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(23, 107, 135, 0.18);
  border-color: var(--primary);
}

.wide {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

.actions.compact {
  gap: 8px;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.review-list-pane {
  min-width: 0;
  display: grid;
  gap: 10px;
  align-content: start;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filter-grid button {
  grid-column: 1 / -1;
}

.review-list {
  max-height: 62vh;
}

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

.output pre {
  margin: 0;
  padding: 12px;
  overflow: auto;
  flex: 1;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assistant-widget {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  width: min(420px, calc(100vw - 28px));
  color: var(--text);
}

.assistant-toggle {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.assistant-widget:not(.collapsed) .assistant-toggle {
  display: none;
}

.assistant-panel {
  display: grid;
  grid-template-rows: auto auto minmax(220px, 46vh) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(16, 24, 40, 0.18);
}

.assistant-widget.collapsed .assistant-panel {
  display: none;
}

.assistant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.assistant-head strong,
.assistant-head span {
  display: block;
}

.assistant-head span {
  color: var(--muted);
  font-size: 12px;
}

.assistant-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.assistant-quick {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.assistant-quick button {
  min-height: 30px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--primary);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 5px 9px;
}

.assistant-messages {
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 12px;
  overflow: auto;
  background: #f6f7f9;
}

.assistant-message {
  max-width: 92%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assistant-message.user {
  justify-self: end;
  color: #ffffff;
  border-color: var(--primary);
  background: var(--primary);
}

.assistant-message.assistant {
  justify-self: start;
}

.assistant-meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.assistant-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.assistant-input textarea {
  min-height: 42px;
  max-height: 120px;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 280px 1fr;
    height: auto;
  }

  .output {
    grid-column: 1 / -1;
    min-height: 320px;
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .tabs,
  .form-grid,
  .tool-grid,
  .upload-fields,
  .materials-status,
  .review-layout,
  .review-editor {
    grid-template-columns: 1fr;
  }

  .item-list {
    max-height: 260px;
  }

  .assistant-widget {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }

  .assistant-panel {
    grid-template-rows: auto auto minmax(220px, 52vh) auto;
  }

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