:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #111827;
  --muted: #64748b;
  --line: #d9e1ee;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --cyan: #0891b2;
  --green: #dcfce7;
  --green-text: #15803d;
  --amber: #fef3c7;
  --amber-text: #b45309;
  --red: #fee2e2;
  --red-text: #b91c1c;
  --slate: #e2e8f0;
  --slate-text: #475569;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent 260px),
    var(--bg);
}

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

button {
  border: 0;
  cursor: pointer;
}

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

a {
  color: inherit;
}

.shell {
  min-height: 100vh;
  padding: 28px 16px 64px;
}

#userView {
  max-width: 760px;
  margin: 0 auto;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.link-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.link-row {
  display: grid;
  grid-template-columns: 48px 1fr 20px;
  gap: 14px;
  align-items: center;
  min-height: 76px;
  padding: 14px 16px;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.link-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  border-radius: 8px;
}

.link-row b {
  display: block;
  margin-bottom: 4px;
  font-size: 17px;
}

.link-row em {
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
}

.link-row strong {
  color: var(--blue);
  font-size: 24px;
}

.panel,
.admin-sidebar,
.admin-main {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  margin-bottom: 14px;
  padding: 24px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 18px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.35;
}

label {
  display: block;
  margin-bottom: 14px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

label span::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  background: var(--cyan);
  border-radius: 50%;
  vertical-align: 2px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: 0;
}

textarea {
  min-height: 124px;
  padding: 12px 13px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.primary,
.ghost,
.small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 900;
  border-radius: 8px;
}

.primary {
  width: 100%;
  margin-top: 6px;
  color: #fff;
  font-size: 18px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.22);
}

.ghost {
  width: 100%;
  margin-top: 10px;
  color: var(--blue);
  background: #edf4ff;
  border: 1px solid #c7d8ff;
}

.small {
  width: auto;
  min-height: 36px;
  padding: 0 13px;
  color: #fff;
  font-size: 14px;
  background: var(--blue);
}

.section-title,
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title h2,
.row-between h3 {
  margin-bottom: 0;
}

.custom-box {
  padding: 16px;
  margin-bottom: 14px;
  background: #f0f7ff;
  border: 1px solid #c5d9f8;
  border-radius: 8px;
}

.custom-box p {
  margin: 12px 0;
  color: var(--muted);
  line-height: 1.7;
}

.custom-box span,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
  background: #dbeafe;
  border-radius: 999px;
}

.activity-list,
.task-list {
  display: grid;
  gap: 12px;
}

.activity-modal {
  align-items: end;
}

.activity-modal-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  width: min(760px, 100%);
  max-height: min(88vh, 860px);
  padding: 24px;
  background: #fff;
  border-radius: 16px 16px 8px 8px;
  box-shadow: var(--shadow);
}

.modal-title {
  margin-bottom: 18px;
}

.modal-title .close {
  position: static;
  flex: 0 0 auto;
}

.activity-toolbar {
  margin: 2px 0 12px;
}

.activity-modal .activity-list {
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.activity-card,
.task-card {
  padding: 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.activity-card {
  display: grid;
  grid-template-columns: 152px 1fr;
  gap: 12px;
  align-items: stretch;
  width: 100%;
}

.activity-image {
  width: 100%;
  height: 112px;
  object-fit: cover;
  background: #e2e8f0;
  border-radius: 8px;
}

.activity-image.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
}

.activity-card-body {
  min-width: 0;
}

.activity-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.select-hint {
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
}

.activity-empty {
  padding: 18px;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.activity-card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.activity-card h3,
.task-card h3 {
  margin-bottom: 6px;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
}

.status {
  display: inline-flex;
  min-height: 28px;
  padding: 0 10px;
  align-items: center;
  white-space: nowrap;
  color: var(--amber-text);
  font-size: 13px;
  font-weight: 900;
  background: var(--amber);
  border-radius: 999px;
}

.status.success,
.status.waiting_result,
.status.active {
  color: var(--green-text);
  background: var(--green);
}

.status.failed,
.status.cancelled,
.status.disabled {
  color: var(--red-text);
  background: var(--red);
}

.status.created,
.status.waiting {
  color: var(--blue);
  background: #dbeafe;
}

.status.running {
  color: #fff;
  background: var(--blue);
}

.status.used {
  color: var(--slate-text);
  background: var(--slate);
}

.sticky-action {
  position: sticky;
  bottom: 14px;
}

.modal-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: 12px;
  padding-top: 14px;
  background: #fff;
}

.modal-actions .ghost,
.modal-actions .primary {
  margin-top: 0;
}

.page-back {
  color: #fff;
  text-decoration: none;
}

.query-page {
  max-width: 760px;
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 16px;
  color: #fff;
  background: rgba(15, 23, 42, 0.94);
  border-radius: 8px;
  transform: translateX(-50%);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.54);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  width: min(500px, 100%);
  padding: 34px 24px 24px;
  text-align: center;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  color: #334155;
  font-size: 26px;
  background: #eef2f7;
  border-radius: 8px;
}

.check {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  margin: 0 auto 16px;
  color: var(--green-text);
  font-size: 44px;
  background: var(--green);
  border-radius: 50%;
}

.admin {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 16px;
  max-width: 1240px;
  margin: 0 auto;
}

.admin-sidebar {
  position: sticky;
  top: 20px;
  height: fit-content;
  padding: 18px;
}

.admin-sidebar h1 {
  margin-bottom: 18px;
  font-size: 22px;
}

.admin-sidebar button,
.admin-sidebar a {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  padding: 0 12px;
  margin-bottom: 7px;
  color: #334155;
  font-weight: 800;
  text-decoration: none;
  background: transparent;
  border-radius: 8px;
}

.admin-sidebar button.active {
  color: #fff;
  background: var(--blue);
}

.admin-sidebar a {
  color: var(--cyan);
}

.admin-main {
  min-width: 0;
  padding: 22px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
  margin-bottom: 14px;
}

.table {
  margin-top: 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

.table th {
  color: #334155;
  font-size: 13px;
  background: #f1f5f9;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.log-list {
  display: grid;
  gap: 9px;
}

.log-item {
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.log-item small {
  color: var(--muted);
}

.hint {
  margin: 12px 0 16px;
  padding: 12px 14px;
  color: #334155;
  line-height: 1.7;
  background: #f8fafc;
  border-left: 4px solid var(--cyan);
  border-radius: 8px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-row .small {
  min-height: 32px;
  padding: 0 11px;
}

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

  .user-header {
    align-items: flex-start;
  }

  .panel {
    padding: 18px;
  }

  h1 {
    font-size: 25px;
  }

  h2 {
    font-size: 20px;
  }

  .link-row {
    grid-template-columns: 42px 1fr 16px;
    min-height: 68px;
    padding: 12px;
  }

  .link-icon {
    width: 40px;
    height: 40px;
  }

  .link-row b {
    font-size: 15px;
  }

  .link-row em {
    font-size: 13px;
  }

  .section-title,
  .row-between {
    align-items: flex-start;
  }

  .activity-card {
    grid-template-columns: 1fr;
  }

  .activity-modal-card {
    max-height: 92vh;
    padding: 18px;
  }

  .activity-toolbar {
    display: grid;
  }

  .activity-image {
    height: 168px;
  }

  .modal-actions {
    grid-template-columns: 1fr 1.25fr;
  }

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

  .admin-sidebar {
    position: static;
  }

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

  .admin-sidebar h1 {
    grid-column: 1 / -1;
  }

  .admin-sidebar button,
  .admin-sidebar a {
    margin-bottom: 0;
  }

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