:root {
  --bg: #eef5ee;
  --panel: #fbfdf9;
  --panel-strong: #f4f9f1;
  --text: #17231b;
  --muted: #647266;
  --line: #d8e4d7;
  --bamboo: #2f7d53;
  --bamboo-deep: #1f5d3d;
  --mint: #cfe8d3;
  --danger: #c34848;
  --warning: #9b6b18;
  --shadow: 0 18px 48px rgba(38, 78, 45, 0.12);
  font-family:
    Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(31, 93, 61, 0.09) 0 2px, transparent 2px 96px),
    linear-gradient(135deg, rgba(251, 253, 249, 0.74), rgba(231, 241, 229, 0.88)),
    repeating-linear-gradient(115deg, rgba(31, 93, 61, 0.06) 0 1px, transparent 1px 22px),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 78%, rgba(31, 93, 61, 0.18) 78% 78.5%, transparent 78.5%),
    linear-gradient(130deg, transparent 0 64%, rgba(47, 125, 83, 0.12) 64% 65%, transparent 65%),
    linear-gradient(55deg, transparent 0 70%, rgba(47, 125, 83, 0.11) 70% 71%, transparent 71%);
  opacity: 0.7;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
}

.workbench,
.side,
.admin-content {
  display: grid;
  gap: 16px;
  align-content: start;
}

.topbar {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--bamboo-deep);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 3vw, 44px);
  line-height: 1.08;
}

h2 {
  font-size: 18px;
}

.panel {
  background: rgba(251, 253, 249, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span,
.hint,
.meter {
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 12px 13px;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

textarea {
  min-height: 190px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--bamboo);
  box-shadow: 0 0 0 3px rgba(47, 125, 83, 0.12);
}

.session-preview,
.actions,
.channel-bar,
.section-head,
.result-head,
.progress-head,
.link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.section-head,
.result-head,
.progress-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.chip,
.expiry {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--bamboo-deep);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 650;
}

.actions {
  margin-top: 12px;
}

.channel-bar {
  margin: -2px 0 14px;
}

button,
.admin-link {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 15px;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

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

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

.danger-btn {
  border-color: rgba(195, 72, 72, 0.4);
  color: var(--danger);
}

.solid-btn {
  background: var(--text);
  color: #fff;
}

.ghost-btn,
.small-btn,
.admin-link {
  background: rgba(255, 255, 255, 0.72);
}

.channel-btn.active {
  border-color: var(--bamboo);
  background: var(--panel-strong);
  color: var(--bamboo-deep);
  box-shadow: inset 0 0 0 1px rgba(47, 125, 83, 0.18);
}

.small-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.danger-mini {
  color: var(--danger);
  border-color: rgba(195, 72, 72, 0.28);
}

.bar {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1ebdf;
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--bamboo), #72a86f);
  transition: width 0.28s ease;
}

.progress-head strong {
  font-size: 28px;
  color: var(--bamboo-deep);
}

.link-row {
  flex-wrap: nowrap;
}

.link-row input {
  flex: 1;
  min-width: 0;
}

.qr-wrap {
  min-height: 250px;
  margin-top: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
}

.qr-wrap img {
  width: min(260px, 80vw);
  height: auto;
  image-rendering: pixelated;
}

.qr-empty {
  color: #a3afa4;
  font-size: 32px;
  font-weight: 800;
}

.stat-panel {
  display: grid;
  gap: 12px;
}

.stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.stat:last-child {
  border-bottom: 0;
}

.stat strong {
  color: var(--bamboo-deep);
  font-size: 30px;
}

.stat span {
  color: var(--muted);
}

.log-list {
  display: grid;
  gap: 8px;
  max-height: 330px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.log-list li,
.table-row,
.empty-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.log-list li span,
.table-row span {
  color: var(--muted);
  font-size: 12px;
}

.log-list li.error strong {
  color: var(--danger);
}

.log-list li.success strong {
  color: var(--bamboo-deep);
}

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

.proxy-grid textarea {
  min-height: 240px;
}

.code-box {
  min-height: 120px;
  margin-top: 12px;
  font-family: "Cascadia Mono", Consolas, monospace;
}

.table-list {
  display: grid;
  gap: 8px;
}

.table-row {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
}

.table-row strong,
.table-row span {
  display: block;
}

.compact .table-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.job-row {
  width: 100%;
  min-height: auto;
  text-align: left;
  cursor: pointer;
}

.job-row.selected,
.job-row:hover {
  border-color: var(--bamboo);
  box-shadow: 0 0 0 3px rgba(47, 125, 83, 0.1);
}

.job-detail-panel {
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.detail-grid {
  display: grid;
  gap: 8px;
}

.detail-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

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

.detail-item strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.detail-action {
  width: 100%;
  margin-top: 10px;
}

.detail-subhead {
  margin: 14px 0 8px;
  font-size: 14px;
}

.detail-log {
  max-height: 260px;
}

.maintenance-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(238, 245, 238, 0.86);
  backdrop-filter: blur(8px);
}

.maintenance-overlay[hidden] {
  display: none !important;
}

.maintenance-box {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 24px;
}

.maintenance-box h2 {
  margin-bottom: 10px;
  font-size: 28px;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    grid-template-columns: 1fr;
    padding: 18px 0;
  }

  .admin-grid,
  .proxy-grid,
  .table-row,
  .compact .table-row {
    grid-template-columns: 1fr;
  }

  .link-row {
    flex-wrap: wrap;
  }

  .link-row input,
  .link-row button {
    width: 100%;
  }
}
