:root {
  --bg: #f5efe4;
  --surface: rgba(255, 251, 244, 0.9);
  --surface-strong: #fffdf8;
  --surface-ink: #132a33;
  --text: #17323d;
  --muted: #6e7f86;
  --line: rgba(23, 50, 61, 0.14);
  --shadow: 0 24px 60px rgba(27, 47, 58, 0.14);
  --primary: #d8743a;
  --primary-deep: #b55b28;
  --secondary: #0f6a74;
  --success: #147b4e;
  --danger: #b6433a;
  --font-main: "Segoe UI Variable", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --font-display: "Trebuchet MS", "Microsoft YaHei UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-main);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.88), transparent 32%),
    radial-gradient(circle at right 10%, rgba(15, 106, 116, 0.15), transparent 28%),
    linear-gradient(135deg, #f9f2e7 0%, #f0e3c8 40%, #e3efe8 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

body::before {
  top: 48px;
  right: -50px;
  background: rgba(216, 116, 58, 0.14);
}

body::after {
  bottom: 0;
  left: -70px;
  background: rgba(15, 106, 116, 0.14);
}

.front-shell,
.admin-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.admin-shell {
  width: min(1880px, calc(100% - 20px));
}

.panel,
.login-card,
.modal-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  border-radius: 24px;
  padding: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  font-weight: 700;
}

.admin-topbar h1,
.login-card h1 {
  margin: 6px 0 10px;
  font: 700 2rem/1.1 var(--font-display);
}

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

.section-head h2,
.toolbar h2,
.api-box h3 {
  margin: 0;
  font-size: 1.1rem;
}

.flow-panel {
  position: relative;
  overflow: hidden;
}

.flow-panel::after {
  content: "";
  position: absolute;
  right: -50px;
  top: -50px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(216, 116, 58, 0.08);
}

.flow-box,
textarea,
input,
select,
button {
  font-family: var(--font-main);
}

.flow-box,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
  color: var(--surface-ink);
  padding: 16px;
  line-height: 1.75;
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.compact {
  margin: 0;
}

.stack-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.meta-label {
  color: var(--muted);
  font-size: 0.88rem;
}

.field input,
.field select,
.field textarea,
.search-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--surface-ink);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-input:focus {
  border-color: rgba(15, 106, 116, 0.45);
  box-shadow: 0 0 0 4px rgba(15, 106, 116, 0.12);
  transform: translateY(-1px);
}

.primary-btn,
.ghost-btn,
.small-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.primary-btn:hover,
.ghost-btn:hover,
.small-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  box-shadow: 0 16px 30px rgba(181, 91, 40, 0.22);
}

.ghost-btn,
.small-btn {
  color: var(--secondary);
  background: rgba(15, 106, 116, 0.1);
}

.small-btn {
  padding: 8px 12px;
  font-size: 0.86rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(216, 116, 58, 0.12);
  color: var(--primary-deep);
  font-size: 0.85rem;
  font-weight: 700;
}

.badge-soft {
  background: rgba(15, 106, 116, 0.1);
  color: var(--secondary);
}

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

.inline-message {
  min-height: 24px;
  margin: 0;
  color: var(--primary-deep);
}

.hidden {
  display: none !important;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(15, 106, 116, 0.08);
  border: 1px solid rgba(15, 106, 116, 0.16);
  cursor: pointer;
}

.chip.active {
  background: rgba(216, 116, 58, 0.12);
  border-color: rgba(216, 116, 58, 0.28);
  color: var(--primary-deep);
}

.task-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(253, 249, 241, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  padding: 22px;
}

.task-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.task-action-wrap {
  margin-bottom: 18px;
}

.loading-box {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px 16px;
  margin: 12px 0 18px;
  border-radius: 22px;
  background: rgba(15, 106, 116, 0.08);
}

.loading-countdown {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(15, 106, 116, 0.15);
  border-top-color: var(--secondary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.qr-section {
  display: grid;
  justify-items: center;
  gap: 16px;
  margin: 18px 0 22px;
  padding: 22px;
  border-radius: 24px;
  background: rgba(15, 106, 116, 0.08);
  text-align: center;
}

.countdown-text {
  margin: 0;
  color: var(--primary-deep);
  font-weight: 700;
}

.qr-frame {
  display: grid;
  place-items: center;
  width: 240px;
  min-height: 240px;
  background: #fff;
  border-radius: 24px;
  box-shadow: inset 0 0 0 1px rgba(19, 42, 51, 0.06);
}

.qr-canvas {
  min-height: 184px;
  min-width: 184px;
}

.status-note {
  margin: 0;
  font-size: 1rem;
  color: var(--secondary);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 320px;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(19, 42, 51, 0.92);
  color: #fff;
  box-shadow: 0 22px 44px rgba(19, 42, 51, 0.24);
  z-index: 20;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 20px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(247, 239, 224, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 1.9rem;
  font-family: var(--font-display);
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.tab-btn {
  border: none;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--secondary), #13515a);
  color: #fff;
  box-shadow: 0 16px 32px rgba(15, 106, 116, 0.2);
}

.tab-panel {
  display: none;
}

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

.toolbar {
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.card-generate-row,
.card-filter-row {
  flex-wrap: wrap;
}

.task-toolbar-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px 18px;
  margin-bottom: 18px;
}

.task-search-row {
  flex-wrap: nowrap;
  min-width: 0;
}

.task-action-row {
  justify-content: flex-end;
}

.task-page-row {
  align-self: center;
}

.task-nav-row {
  justify-content: flex-end;
  white-space: nowrap;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 12px;
}

.small-field input {
  width: 120px;
}

.wide-input {
  min-width: 0;
  flex: 1 1 220px;
  max-width: 260px;
}

.table-wrap {
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 20px;
  border: 1px solid rgba(19, 42, 51, 0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.9);
}

.cards-table,
.logs-table {
  table-layout: auto;
}

.tasks-table {
  table-layout: fixed;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(19, 42, 51, 0.08);
  vertical-align: top;
}

.tasks-table th,
.tasks-table td {
  padding: 12px 8px;
  font-size: 0.88rem;
}

.tasks-table th:nth-child(1),
.tasks-table td:nth-child(1) {
  width: 44px;
}

.tasks-table th:nth-child(2),
.tasks-table td:nth-child(2) {
  width: 52px;
}

.tasks-table th:nth-child(3),
.tasks-table td:nth-child(3) {
  width: 146px;
  white-space: nowrap;
}

.tasks-table th:nth-child(4),
.tasks-table td:nth-child(4) {
  width: 216px;
  white-space: nowrap;
}

.tasks-table th:nth-child(5),
.tasks-table td:nth-child(5) {
  width: 128px;
  white-space: nowrap;
}

.tasks-table th:nth-child(6),
.tasks-table td:nth-child(6) {
  width: 128px;
  white-space: nowrap;
}

.tasks-table th:nth-child(7),
.tasks-table td:nth-child(7) {
  width: 84px;
  white-space: nowrap;
}

.tasks-table th:nth-child(8),
.tasks-table td:nth-child(8) {
  width: 164px;
  white-space: nowrap;
}

.tasks-table th:nth-child(9),
.tasks-table td:nth-child(9) {
  width: 176px;
}

.tasks-table th:nth-child(10),
.tasks-table td:nth-child(10) {
  width: 104px;
}

.ghost-btn.active {
  background: linear-gradient(135deg, var(--secondary), #13515a);
  color: #fff;
  box-shadow: 0 12px 24px rgba(15, 106, 116, 0.18);
}

thead th {
  position: sticky;
  top: 0;
  background: rgba(249, 244, 234, 0.98);
  color: var(--secondary);
  font-size: 0.9rem;
}

tbody tr:hover {
  background: rgba(15, 106, 116, 0.04);
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.remark-editor {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.remark-editor textarea {
  min-height: 68px;
  padding: 10px;
  border-radius: 14px;
}

.tasks-table .table-actions {
  gap: 6px;
}

.tasks-table .small-btn {
  padding: 7px 10px;
  font-size: 0.82rem;
}

.tasks-table strong {
  font-size: 0.85rem;
}

.tasks-table td:nth-child(9) textarea {
  font-size: 0.84rem;
  line-height: 1.5;
}

.desktop-only {
  display: block;
}

.mobile-only {
  display: none;
}

.mobile-shell {
  position: relative;
  z-index: 1;
  width: min(100% - 20px, 560px);
  margin: 0 auto;
  padding: 14px 0 28px;
}

.mobile-shell .panel {
  padding: 18px;
  border-radius: 20px;
}

.mobile-shell .section-head {
  align-items: flex-start;
  gap: 10px;
}

.mobile-shell .section-head h2 {
  font-size: 1rem;
}

.mobile-shell .task-card {
  padding: 16px;
  border-radius: 18px;
}

.mobile-shell .task-summary {
  grid-template-columns: 1fr;
  gap: 12px;
}

.mobile-shell .qr-section {
  padding: 18px 14px;
  border-radius: 18px;
  margin: 16px 0 18px;
}

.mobile-shell .qr-frame {
  width: 220px;
  min-height: 220px;
}

.mobile-shell .field input,
.mobile-shell .field textarea,
.mobile-shell .search-input {
  padding: 13px 14px;
  font-size: 0.92rem;
}

.mobile-shell .primary-btn,
.mobile-shell .ghost-btn {
  width: 100%;
  justify-content: center;
}

.mobile-saved-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-saved-head .ghost-btn {
  width: auto;
  flex: 0 0 auto;
}

.settings-panel {
  display: grid;
  gap: 18px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(15, 106, 116, 0.08);
}

.switch-row input {
  width: 24px;
  height: 24px;
}

.api-box {
  padding: 18px;
  border-radius: 20px;
  background: rgba(19, 42, 51, 0.04);
}

.login-card {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 26px;
  align-items: center;
  margin-top: 56px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(19, 42, 51, 0.4);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 30;
}

.modal-card {
  width: min(720px, 100%);
}

input[type="checkbox"] {
  accent-color: var(--secondary);
}

@media (max-width: 980px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-topbar,
  .login-card {
    grid-template-columns: 1fr;
    display: grid;
  }

  .task-summary {
    grid-template-columns: 1fr;
  }

  .task-toolbar-grid {
    grid-template-columns: 1fr;
  }

  .task-search-row,
  .task-action-row,
  .task-nav-row {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .front-shell,
  .admin-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .panel,
  .login-card,
  .modal-card {
    padding: 18px;
    border-radius: 20px;
  }

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

  .wide-input {
    min-width: 0;
  }

  .qr-frame {
    width: 100%;
  }
}
