:root {
  --bg: #eef2f6;
  --ink: #182131;
  --muted: #667386;
  --line: #d9e1eb;
  --panel: #ffffff;
  --section: #f8fafc;
  --accent: #196f5d;
  --accent-strong: #0f5748;
  --danger: #a33b24;
  --ok: #176c45;
  --soft: #e6f2ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #dce8ef 0, #eef2f6 220px),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

.shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 18px;
}

.app-card,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(25, 37, 54, .10);
}

.app-card {
  overflow: hidden;
  min-height: calc(100vh - 36px);
}

.hero {
  min-height: 118px;
  padding: 24px 30px;
  color: #fff;
  background:
    linear-gradient(120deg, rgba(18, 72, 84, .95), rgba(28, 99, 76, .95)),
    repeating-linear-gradient(135deg, rgba(255,255,255,.13) 0 1px, transparent 1px 18px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 32px;
  letter-spacing: 0;
}

.hero p {
  margin: 0;
  max-width: 680px;
  color: rgba(255,255,255,.84);
  line-height: 1.6;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(255,255,255,.14);
  font-size: 14px;
  white-space: nowrap;
}

.user-pill {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,.38);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(255,255,255,.22);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

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

.logout-link {
  color: #fff;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255,255,255,.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 42vw);
  gap: 18px;
  padding: 18px;
  align-items: start;
}

.work-main {
  display: grid;
  gap: 16px;
}

.model-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--section);
}

.model-bar span,
.summary-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.model-bar strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.section {
  background: var(--section);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

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

.section-head h2,
.result-band h2 {
  margin: 0;
  font-size: 18px;
}

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

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

label > span {
  font-weight: 700;
  color: var(--ink);
}

.field-title {
  display: block;
  margin-bottom: 7px;
  font-weight: 700;
  color: var(--ink);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

input[type="file"] {
  padding: 9px;
}

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

input:focus,
textarea:focus {
  outline: 2px solid rgba(25, 111, 93, .18);
  border-color: var(--accent);
}

small {
  color: var(--muted);
  line-height: 1.5;
}

.field-error {
  margin: -6px 0 14px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
}

.field-hint {
  min-height: 20px;
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.field-hint.ok {
  color: var(--ok);
  font-weight: 700;
}

.field-hint.error {
  color: var(--danger);
  font-weight: 700;
}

.upload-box {
  display: grid;
  gap: 12px;
  min-height: 176px;
  margin-bottom: 0;
  padding: 26px;
  border: 2px dashed #9cb9e8;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 14px;
}

.material-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.native-file-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid #cfd9e8;
  border-radius: 6px;
  background: #fff;
}

.native-file-row input[type="file"] {
  padding: 0;
  border: 0;
  background: transparent;
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.two-cols.compact {
  grid-template-columns: 150px 1fr;
  align-items: end;
}

.score-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
  align-items: end;
}

.config-note {
  margin: 0 0 15px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.api-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.settings-dialog {
  width: min(760px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 24px 64px rgba(20, 30, 45, .24);
}

.settings-dialog::backdrop {
  background: rgba(15, 25, 38, .42);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.dialog-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.dialog-head p {
  margin: 0;
  color: var(--muted);
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.test-status {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.test-status.ok {
  color: var(--ok);
  font-weight: 700;
}

.test-status.error {
  color: var(--danger);
  font-weight: 700;
}

.test-result {
  margin-top: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  line-height: 1.5;
}

.test-result.ok {
  border-color: #b9ddce;
  background: #edf8f2;
  color: var(--ok);
  font-weight: 700;
}

.test-result.error {
  border-color: #efc8ba;
  background: #fff6f2;
  color: var(--danger);
  font-weight: 700;
}

.file-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 2px 0 16px;
}

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

.file-metrics strong,
.file-metrics span {
  display: block;
}

.file-metrics strong {
  font-size: 18px;
  color: var(--ink);
}

.file-metrics span {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.progress-panel {
  margin: 4px 0 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
}

.progress-head strong {
  color: var(--ink);
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe6ee;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #35a27a);
  transition: width .18s ease;
}

.progress-panel.working .progress-track {
  position: relative;
}

.progress-panel.working .progress-bar {
  width: 100% !important;
  background: linear-gradient(90deg, #196f5d 0%, #35a27a 45%, #196f5d 90%);
  background-size: 220% 100%;
  animation: progress-stripe 1.2s linear infinite;
}

.progress-panel.error {
  border-color: #efc8ba;
  background: #fff6f2;
}

.progress-panel.error .progress-head,
.progress-panel.error .progress-head strong {
  color: var(--danger);
}

.progress-panel.error .progress-bar {
  width: 100% !important;
  background: var(--danger);
}

@keyframes progress-stripe {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 220% 0;
  }
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 6px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

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

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

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

.button.secondary:hover {
  border-color: var(--accent-strong);
  color: var(--accent-strong);
  background: #f4fbf8;
}

.button:disabled {
  cursor: wait;
  opacity: .72;
}

.button.full {
  width: 100%;
}

.result-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  margin: 18px 22px 0;
  border: 1px solid #b9ddce;
  border-radius: 8px;
  background: var(--soft);
}

.result-band p {
  margin: 6px 0 0;
  color: var(--muted);
}

.alert {
  padding: 14px 16px;
  margin: 18px 22px 0;
  color: var(--danger);
  border: 1px solid #efc8ba;
  border-radius: 8px;
  background: #fff6f2;
}

.alert.ok {
  color: var(--ok);
  border-color: #b9ddce;
  background: #edf8f2;
}

.summary-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(25, 37, 54, .10);
  overflow: hidden;
}

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

.summary-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.summary-table {
  overflow: auto;
}

.empty-summary {
  align-self: start;
  margin: 16px;
  padding: 18px;
  border: 1px dashed #b7c7d8;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--muted);
}

.empty-summary strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.empty-summary p {
  margin: 0;
  line-height: 1.6;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(25, 37, 54, .10);
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

.auth-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.auth-link {
  margin-top: 16px !important;
  text-align: center;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--soft);
  font-weight: 700;
  white-space: nowrap;
}

td:nth-child(3) {
  width: 90px;
  font-weight: 700;
}

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

  .hero,
  .result-band {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace,
  .hero {
    padding: 18px;
  }

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

  .summary-panel {
    position: static;
    max-height: none;
  }

  .two-cols,
  .two-cols.compact,
  .score-row,
  .material-grid,
  .file-metrics {
    grid-template-columns: 1fr;
  }

  .status-pill {
    white-space: normal;
  }
}
