:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --ink: #121926;
  --ink-soft: #334155;
  --muted: #667085;
  --line: #d9e0e8;
  --line-soft: #e8edf2;
  --nav: #0f1726;
  --nav-2: #172234;
  --nav-line: rgba(255, 255, 255, 0.1);
  --primary: #0b7285;
  --primary-strong: #075c6a;
  --primary-soft: #e7f6f8;
  --accent: #c8553d;
  --accent-soft: #fff0e8;
  --ok: #11845b;
  --ok-soft: #e9f8f0;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --warning: #b76e00;
  --warning-soft: #fff7df;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 16px 42px rgba(16, 24, 40, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(232, 240, 247, 0.85) 0, rgba(244, 246, 248, 0) 280px),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

button,
a,
input,
select,
textarea {
  outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: 0 0 0 3px rgba(11, 114, 133, 0.18);
  border-color: var(--primary);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
    var(--nav);
  color: #eef4ff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 0 4px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #d96545, #a9402d);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 28px rgba(201, 82, 57, 0.28);
  font-weight: 800;
  color: #fff;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.metric span,
.metric strong {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.15;
}

.brand p {
  color: #aebbd0;
  font-size: 13px;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  min-height: 42px;
  text-align: left;
  border-radius: 8px;
  padding: 10px 12px;
  color: #dce6f5;
  background: transparent;
  border: 1px solid transparent;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.nav-item.active {
  background: var(--nav-2);
  border-color: var(--nav-line);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.token-box {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--nav-line);
}

.token-box label {
  color: #b7c3d8;
  margin: 0;
}

.token-box input {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.token-box input::placeholder {
  color: #8fa0b8;
}

.content {
  min-width: 0;
  padding: 28px clamp(20px, 3vw, 38px);
  overflow-x: hidden;
}

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

.topbar h2 {
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.05;
  color: #0f172a;
}

.eyebrow {
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.topbar p {
  color: var(--muted);
  margin-top: 8px;
  max-width: 760px;
}

.actions,
.form-actions,
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.status-chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid #b7e3c9;
  border-radius: 999px;
  background: #edfdf4;
  color: #087443;
  font-weight: 700;
  white-space: nowrap;
}

.status-chip span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #12b76a;
  box-shadow: 0 0 0 4px rgba(18, 183, 106, 0.14);
}

.primary,
.ghost,
.segment {
  min-height: 40px;
  border-radius: 7px;
  padding: 8px 15px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 9px 22px rgba(11, 114, 133, 0.18);
}

.primary:hover {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

.ghost {
  background: #eef3f7;
  color: #27364d;
  border-color: var(--line);
}

.ghost:hover {
  background: #e5ebf1;
}

.full {
  width: 100%;
}

.notice {
  border-radius: 8px;
  padding: 11px 13px;
  margin-bottom: 16px;
  background: var(--warning-soft);
  border: 1px solid #f1d38a;
  color: #8a4b00;
  box-shadow: var(--shadow-sm);
}

.hidden {
  display: none !important;
}

.tab-panel {
  display: none;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.metric {
  position: relative;
  min-height: 104px;
  padding: 18px 18px 17px;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto 18px 0;
  height: 3px;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0.8;
}

.metric span {
  color: var(--muted);
  display: block;
  margin-bottom: 10px;
}

.metric strong {
  display: block;
  font-size: 32px;
  line-height: 1;
  color: #111827;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  padding: 17px;
  box-shadow: var(--shadow-md);
}

.panel h3 {
  position: relative;
  font-size: 18px;
  line-height: 1.25;
  margin-bottom: 16px;
  padding-left: 12px;
}

.panel h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: var(--accent);
}

.wide {
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 14px;
  margin-bottom: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(16, 24, 40, 0.02);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #98a2b3;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b8c4d2;
}

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

select[multiple] {
  min-height: 198px;
  padding: 8px;
}

select option {
  padding: 8px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.stack {
  display: grid;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin: 0 0 12px;
  background: #fff;
}

.segment {
  min-height: 38px;
  border-radius: 0;
  background: transparent;
  border-right: 1px solid var(--line);
  color: var(--ink-soft);
  box-shadow: none;
}

.segment:last-child {
  border-right: 0;
}

.segment.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 700;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin-top: 22px;
  padding: 0 2px;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

pre,
#batchResult {
  margin: 14px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #f8fafc;
  color: #243145;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 96px;
  line-height: 1.55;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  background: #fff;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: var(--surface-muted);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

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

tbody tr:hover {
  background: #fbfcfe;
}

td span {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
}

.pill.ok {
  color: var(--ok);
  background: var(--ok-soft);
}

.pill.off {
  color: var(--danger);
  background: var(--danger-soft);
}

.link-button {
  min-height: 28px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 6px;
  padding: 4px 9px;
}

.link-button:hover {
  background: #ffe1dc;
}

.message-list {
  display: grid;
  gap: 10px;
}

.message-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.message-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.message-item strong {
  word-break: break-word;
}

.message-item p {
  color: var(--muted);
  margin: 0 0 8px;
  word-break: break-word;
}

.doc-panel {
  max-width: 980px;
}

.doc-panel h3 {
  margin-top: 20px;
}

.doc-panel h3:first-child {
  margin-top: 0;
}

.doc-panel pre {
  min-height: auto;
}

.filter-row {
  margin-bottom: 12px;
}

.filter-row input {
  flex: 1;
  min-width: 220px;
}

@media (max-width: 1100px) {
  .work-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

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

  .nav-item {
    text-align: center;
    padding: 9px 8px;
  }

  .nav-item.active {
    box-shadow: inset 0 -3px 0 var(--accent);
  }

  .token-box {
    margin-top: 0;
  }

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

@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  .content {
    padding: 18px 14px 24px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
    justify-content: stretch;
  }

  .actions .ghost {
    flex: 1;
  }

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

  .form-grid.two,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .metric {
    padding: 15px;
  }

  .form-actions {
    align-items: stretch;
  }

  .form-actions .primary,
  .form-actions .ghost {
    flex: 1 1 150px;
  }

  .segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .segment {
    width: 100%;
  }

  .message-item header {
    flex-direction: column;
    gap: 4px;
  }
}
