:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #1d2633;
  --muted: #657085;
  --line: #d7dfe9;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #047857;
  --shadow: 0 14px 34px rgba(20, 32, 50, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}
.login-brand { margin-bottom: 6px; }
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}
.brand h1, .topbar h2 { margin: 0; letter-spacing: 0; }
.brand p, .topbar p, .panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
label { display: grid; gap: 6px; }
label span { color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
  border: 1px solid #cfd6e2;
  border-radius: 6px;
  outline: none;
}
textarea {
  min-height: 132px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.login-actions, .top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}
.inline-field {
  display: grid;
  gap: 4px;
}
.inline-field span,
.inline-field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.lang-field {
  min-width: 190px;
}
.login-actions .lang-field {
  margin-right: auto;
}
.login-tip, .server-note, .field-help {
  color: var(--muted);
  font-size: 12px;
}
.attach-helper-box {
  display: grid;
  gap: 8px;
}
.item-search-row {
  position: relative;
}
.item-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  background: #fff;
  border: 1px solid #cfd6e2;
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.item-result,
.item-result-empty {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  text-align: left;
  background: #fff;
  border: 0;
  border-bottom: 1px solid #edf1f6;
  border-radius: 0;
}
.item-result:hover {
  background: #f8fafc;
}
.item-result strong {
  font-size: 13px;
  color: var(--text);
}
.item-result span,
.item-result-empty {
  color: var(--muted);
  font-size: 12px;
}
.attach-helper {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(110px, 0.7fr) auto auto;
  gap: 8px;
  align-items: center;
}
.attach-helper input {
  min-height: 36px;
}
.attach-helper button {
  min-height: 36px;
  white-space: nowrap;
}
.login-msg {
  min-height: 72px;
  margin: 0;
  padding: 10px;
  background: #111827;
  color: #d1d5db;
  border-radius: 6px;
  white-space: pre-wrap;
}
.login-msg.compact {
  min-height: 44px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  background: #1f2937;
  color: #f9fafb;
  padding: 22px 16px;
}
.brand { padding: 6px 8px 24px; border-bottom: 1px solid rgba(255,255,255,0.14); }
.sidebar .brand p { color: #cbd5e1; }
.nav { display: grid; gap: 8px; margin-top: 18px; }
.nav button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: #e5e7eb;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.nav button.active, .nav button:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
}
.nav small { color: #9ca3af; }
.main { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
  padding: 18px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar h2 { font-size: 24px; }
.top-actions {
  flex-wrap: wrap;
  max-width: 560px;
}
.top-actions .lang-field {
  width: 220px;
}
.top-actions .lang-field select {
  min-height: 36px;
}
.top-actions .lang-field small {
  max-width: 220px;
}
.status-pill {
  min-width: 88px;
  padding: 8px 12px;
  text-align: center;
  color: var(--warn);
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 999px;
}
.status-pill.ok { color: var(--ok); background: #ecfdf5; border-color: #a7f3d0; }
.status-pill.fail { color: var(--danger); background: #fef2f2; border-color: #fecaca; }
.layout {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(420px, 1fr);
  gap: 18px;
  padding: 22px 28px 30px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.command-panel { grid-row: span 2; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h3 { margin: 0; font-size: 17px; }
.form-grid, .dynamic-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.wide, .field-full { grid-column: 1 / -1; }
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.meta-row span {
  padding: 5px 9px;
  color: #344054;
  background: #f2f4f7;
  border: 1px solid #e4e7ec;
  border-radius: 999px;
  font-size: 12px;
}
button {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
}
.primary {
  padding: 0 16px;
  color: #fff;
  background: var(--brand);
}
.primary:hover { background: var(--brand-strong); }
.secondary, .icon-btn {
  padding: 0 13px;
  color: #344054;
  background: #fff;
  border-color: #cfd6e2;
}
.secondary:hover, .icon-btn:hover { background: #f8fafc; }
.action-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
pre {
  min-height: 172px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  color: #d1d5db;
  background: #111827;
  border-radius: 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  white-space: pre-wrap;
}
.parsed-result {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.result-field {
  padding: 10px;
  background: #f8fafc;
  border: 1px solid #e4e7ec;
  border-radius: 6px;
}
.result-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.result-field strong {
  display: block;
  word-break: break-all;
  font-size: 14px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid #e4e7ec;
  border-radius: 6px;
}
.data-table th,
.data-table td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid #e4e7ec;
  font-size: 13px;
}
.data-table th {
  color: #344054;
  background: #f2f4f7;
}
.data-table tr:last-child td {
  border-bottom: 0;
}
.result-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.result-summary span {
  padding: 5px 9px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: var(--ok);
  border-radius: 999px;
  font-size: 12px;
}
.history-list { display: grid; gap: 10px; max-height: 300px; overflow: auto; }
.history-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid #e4e7ec;
  border-radius: 6px;
}
.history-item strong { font-size: 14px; }
.history-item span { color: var(--muted); font-size: 12px; }
.history-item button {
  justify-self: start;
  min-height: 30px;
  padding: 0 10px;
  color: var(--brand);
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.42);
}
.modal-card {
  width: min(460px, 100%);
  padding: 20px;
  display: grid;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.modal-card .panel-head {
  margin-bottom: 2px;
}
.modal-card .action-row {
  margin-top: 4px;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .command-panel { grid-row: auto; }
}
@media (max-width: 640px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .form-grid, .dynamic-form { grid-template-columns: 1fr; }
  .wide, .field-full { grid-column: auto; }
  .result-grid { grid-template-columns: 1fr; }
  .attach-helper { grid-template-columns: 1fr 1fr; }
  .action-row, .login-actions, .top-actions { flex-direction: column; align-items: stretch; }
  .login-actions .lang-field { margin-right: 0; }
  .lang-field, .top-actions .lang-field, .top-actions .lang-field small {
    width: 100%;
    max-width: none;
  }
}
