:root {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --panel-soft: #f7fafb;
  --panel-strong: #eef5f4;
  --text: #17212b;
  --muted: #647181;
  --line: #dce4eb;
  --accent: #08746f;
  --accent-strong: #065a56;
  --gold: #a97824;
  --danger: #b3261e;
  --success: #147a43;
  --shadow: 0 16px 38px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, #ffffff 0, #f6f9fb 260px, var(--bg) 100%),
    var(--bg);
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.app-header,
.workspace-card,
.result-panel,
.dialog-content {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.app-header {
  padding: 14px;
  margin-bottom: 14px;
}

.brand-row,
.nav-row,
.brand-block,
.status-row,
.result-header,
.dialog-actions,
.result-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-row,
.nav-row {
  justify-content: space-between;
}

.nav-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.brand-block {
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: #0b4f4c;
  font-weight: 800;
  letter-spacing: 0;
}

.company-name,
.brand-subtitle,
.workspace-toolbar p,
.image-controls p {
  margin: 0;
  color: var(--muted);
}

.company-name {
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}

.brand-subtitle {
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #c9dedb;
  border-radius: 999px;
  color: var(--accent-strong);
  background: #f1faf8;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.tabs,
.admin-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.tab,
.admin-tab {
  min-width: 116px;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab.active,
.admin-tab.active {
  color: #ffffff;
  background: var(--accent);
}

.tool-panel {
  display: none;
}

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

.workspace-card {
  overflow: hidden;
}

.workspace-toolbar,
.image-controls {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.workspace-toolbar p,
.image-controls p {
  margin-top: 6px;
  font-size: 13px;
}

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

.prompt-chip {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  text-align: center;
  font-weight: 800;
}

.prompt-chip:hover {
  border-color: rgba(8, 116, 111, 0.45);
  color: var(--accent-strong);
  background: #f1faf8;
}

.chat-card {
  min-height: calc(100vh - 220px);
  display: grid;
  grid-template-rows: 1fr auto;
}

.chat-thread {
  min-height: 500px;
  max-height: calc(100vh - 340px);
  overflow-y: auto;
  padding: 22px;
  background: #ffffff;
}

.message {
  width: min(860px, 92%);
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.7;
  white-space: pre-wrap;
  background: #ffffff;
}

.message.assistant {
  background: var(--panel-strong);
}

.message.user {
  margin-left: auto;
  border-color: rgba(8, 116, 111, 0.32);
  background: #e5f5f1;
}

.message.system {
  width: 100%;
  color: var(--muted);
  text-align: center;
  border-style: dashed;
  background: var(--panel-soft);
}

.message.pending {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  animation: typingPulse 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingPulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.composer {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 116, 111, 0.14);
}

textarea {
  min-height: 76px;
  resize: vertical;
  padding: 12px 14px;
  line-height: 1.55;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
}

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

.ghost-button {
  color: var(--text);
  border-color: var(--line);
  background: #ffffff;
}

.icon-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--danger);
  border-color: #f0c8c4;
  background: #fff8f7;
  font-size: 13px;
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.full {
  width: 100%;
}

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

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

.upload-card,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.upload-card {
  padding: 14px;
}

.upload-zone {
  position: relative;
  min-height: 210px;
  border: 1px dashed #9fb0c0;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #ffffff, var(--panel-soft));
  overflow: hidden;
}

.upload-zone.dragging {
  border-color: var(--accent);
  background: #edf8f5;
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  z-index: 2;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.empty-upload {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.empty-upload.compact strong {
  color: var(--accent-strong);
}

.empty-upload strong {
  color: var(--text);
  font-size: 20px;
}

.file-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.file-item {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.file-item img {
  width: 54px;
  height: 54px;
  border-radius: 6px;
  object-fit: cover;
  background: #ffffff;
}

.file-meta {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.file-meta strong,
.result-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta span,
.request-id,
.result-summary {
  color: var(--muted);
  font-size: 12px;
}

.control-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.toggle-row {
  display: grid;
  gap: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-message.error,
.result-error {
  color: var(--danger);
}

.result-panel {
  margin-top: 14px;
  padding: 16px;
}

.result-header {
  justify-content: space-between;
  margin-bottom: 14px;
}

.result-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.result-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.result-card.success {
  border-color: rgba(20, 122, 67, 0.25);
}

.result-card.error {
  border-color: rgba(179, 38, 30, 0.25);
}

.result-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.result-title span {
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
}

.result-card.error .result-title span {
  color: var(--danger);
}

.result-card img {
  display: block;
  width: 100%;
  max-height: 420px;
  border-radius: 6px;
  object-fit: contain;
  background: var(--panel-soft);
}

.result-actions {
  justify-content: flex-end;
  margin-top: 10px;
}

.result-error {
  margin: 8px 0;
  line-height: 1.6;
}

.request-id {
  margin: 10px 0 0;
  word-break: break-all;
}

.hidden {
  display: none !important;
}

dialog {
  width: min(420px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(23, 32, 42, 0.42);
}

.wide-dialog {
  width: min(920px, calc(100% - 28px));
}

.dialog-content {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.dialog-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.admin-tabs {
  width: fit-content;
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: grid;
  gap: 14px;
}

.user-create-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.user-list {
  display: grid;
  gap: 10px;
  max-height: min(58vh, 560px);
  overflow-y: auto;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.user-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.user-main strong,
.user-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.user-actions {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) repeat(4, auto);
  gap: 8px;
  align-items: center;
}

.user-actions .icon-button:disabled,
.user-actions .ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

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

.summary-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.summary-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent-strong);
  font-size: 18px;
}

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

.usage-list {
  display: grid;
  gap: 10px;
  max-height: min(54vh, 540px);
  overflow-y: auto;
}

.usage-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(0, 1.25fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.usage-row.success {
  border-left: 4px solid var(--success);
}

.usage-row.error {
  border-left: 4px solid var(--danger);
}

.usage-main,
.usage-detail {
  min-width: 0;
}

.usage-main {
  display: grid;
  gap: 4px;
}

.usage-main strong,
.usage-main span,
.usage-detail {
  overflow-wrap: anywhere;
}

.usage-main span,
.usage-detail {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 12px;
  }

  .brand-row,
  .nav-row,
  .workspace-toolbar,
  .image-controls {
    grid-template-columns: 1fr;
  }

  .brand-row,
  .nav-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-row,
  .tabs {
    width: 100%;
  }

  .status-row .ghost-button,
  .tab {
    flex: 1;
  }

  .prompt-grid,
  .control-strip,
  .image-body,
  .user-create-grid,
  .user-row,
  .user-actions,
  .usage-filter-grid,
  .usage-summary,
  .usage-row {
    grid-template-columns: 1fr;
  }

  .chat-card {
    min-height: calc(100vh - 280px);
  }

  .chat-thread {
    min-height: 420px;
    max-height: none;
    padding: 14px;
  }

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

@media (max-width: 560px) {
  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .file-list,
  .result-list {
    grid-template-columns: 1fr;
  }

  .file-item {
    grid-template-columns: 50px minmax(0, 1fr);
  }

  .file-item .icon-button {
    grid-column: 1 / -1;
  }
}
