:root {
  --pink: #f65d8e;
  --pink-dark: #e94a7e;
  --brand-grad: linear-gradient(135deg, #ff7aa8 0%, #f65d8e 48%, #e8437f 100%);
  --bg: #f2f4fa;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --text: #1c2233;
  --muted: #5b6376;
  --faint: #8d95a8;
  --border: #e7eaf3;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04),
    0 16px 36px -22px rgba(30, 41, 80, 0.22);
  --ok: #0f9d6e;
  --warn: #b96f08;
  --err: #e5484d;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 480px at 4% -10%, rgba(246, 93, 142, 0.1), transparent 62%),
    radial-gradient(800px 420px at 102% -4%, rgba(41, 182, 246, 0.1), transparent 58%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--pink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 22px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--brand-grad);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 10px 22px -12px rgba(246, 93, 142, 0.9);
  flex: 0 0 auto;
}
.brand-text { line-height: 1.15; min-width: 0; }
.brand-title { font-weight: 800; font-size: 16px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--faint); letter-spacing: 0.08em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}
.user-pill strong { color: var(--text); }

/* ---------- layout ---------- */
.layout {
  width: min(1120px, calc(100% - 32px));
  margin: 22px auto 60px;
  display: grid;
  gap: 18px;
}
.hero {
  border-radius: 24px;
  padding: 28px 30px;
  color: #fff;
  background:
    radial-gradient(120% 150% at 100% 0%, rgba(246, 93, 142, 0.42), transparent 55%),
    radial-gradient(90% 130% at 0% 110%, rgba(41, 182, 246, 0.28), transparent 58%),
    linear-gradient(135deg, #1d2236 0%, #141827 55%, #0f1320 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 32px 70px -36px rgba(16, 20, 35, 0.7);
}
.hero h1 { margin: 0; font-size: clamp(26px, 3.2vw, 38px); letter-spacing: -0.02em; }
.hero p { margin: 8px 0 0; color: rgba(255, 255, 255, 0.72); line-height: 1.7; font-size: 14px; }
.hero .step-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.card-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pink);
}
.section-eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--pink); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1 1 220px; }
.row > .shrink { flex: 0 0 auto; }

/* ---------- form controls ---------- */
label.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
label.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="password"], input[type="number"], input[type="datetime-local"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 12px;
  outline: none;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235b6376' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
input:focus, select:focus, textarea:focus {
  background: var(--surface);
  border-color: var(--pink);
  box-shadow: 0 0 0 4px rgba(246, 93, 142, 0.14);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 90px; resize: vertical; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.check-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.check-item input { accent-color: var(--pink); width: 16px; height: 16px; }
.check-item:hover { border-color: #f3b7c9; }
.hint { font-size: 12px; color: var(--faint); line-height: 1.6; }
.error-text { color: var(--err); font-size: 13px; margin-top: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s, box-shadow 0.18s, background 0.18s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px -12px rgba(16, 24, 40, 0.45); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary {
  border-color: transparent;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 10px 22px -12px rgba(246, 93, 142, 0.9);
}
.btn.primary:hover { box-shadow: 0 16px 30px -14px rgba(246, 93, 142, 1); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn.danger { color: var(--err); border-color: #f7c9ca; background: #fff5f5; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 12.5px; border-radius: 999px; }
.btn.block { width: 100%; }

/* ---------- status ---------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.status-pill.ok { color: var(--ok); background: #e9f8f2; border-color: #c8ebdc; }
.status-pill.warn { color: var(--warn); background: #fff5e6; border-color: #f5dfbb; }
.status-pill.err { color: var(--err); background: #ffecec; border-color: #f8cccc; }
.status-pill.run { color: #d93a72; background: #ffeef4; border-color: #f7c9da; }
.bili-state { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.bili-state .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 4px rgba(141, 149, 168, 0.12); }
.bili-state.logged .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(15, 157, 110, 0.15); }
.bili-state strong { font-size: 14px; }
.bili-state span { color: var(--muted); font-size: 12.5px; }

.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; border-radius: 16px; background: var(--surface-2); border: 1px dashed #f3b7c9; }
.qr-box img { width: 190px; height: 190px; image-rendering: pixelated; border-radius: 10px; background: #fff; }

/* ---------- tables / tasks ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--faint); font-weight: 600; font-size: 12px; letter-spacing: 0.04em; }
.table tr:last-child td { border-bottom: none; }

.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
}
.task-item:hover { border-color: #f3b7c9; background: #fff; }
.task-item.active { border-color: var(--pink); background: #fff; }
.task-main { min-width: 0; }
.task-title { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-meta { margin-top: 4px; color: var(--faint); font-size: 12px; }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: 0 0 auto; }
.task-actions { display: flex; gap: 6px; }

.empty { padding: 26px; text-align: center; color: var(--faint); font-size: 13px; border: 1px dashed var(--border); border-radius: 14px; }

.detail-panel { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; word-break: break-word; }
.log-box {
  margin-top: 12px;
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  background: #0e1220;
  color: #dbe3f4;
  font-family: ui-monospace, "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.result-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.result-links a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; background: var(--brand-grad); color: #fff; font-weight: 700; font-size: 12.5px; }

/* ---------- square multi-column task cards ---------- */
.task-view-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.task-view-toggle .view-btn {
  min-height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}
.task-view-toggle .view-btn.active {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 8px 16px -12px rgba(246, 93, 142, 0.9);
}
.task-square-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.task-square {
  aspect-ratio: 1 / 1;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background:
    radial-gradient(90% 70% at 100% 0%, rgba(246, 93, 142, 0.06), transparent 60%),
    var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.16s, border-color 0.18s, box-shadow 0.18s;
}
.task-square:hover {
  transform: translateY(-2px);
  border-color: #f3b7c9;
  box-shadow: 0 22px 38px -26px rgba(30, 41, 80, 0.45);
}
.task-square.status-running,
.task-square.status-preparing,
.task-square.status-starting {
  border-top: 3px solid var(--pink);
}
.task-square.status-succeeded,
.task-square.status-completed { border-top: 3px solid var(--ok); }
.task-square.status-failed { border-top: 3px solid var(--err); }
.task-square-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.task-square-user {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--faint);
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.task-square h3 {
  margin: 12px 0 0;
  font-size: 14.5px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-square-ticket {
  margin-top: 6px;
  color: var(--pink-dark);
  font-size: 12px;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-square-meta {
  margin-top: 8px;
  color: var(--faint);
  font-size: 11.5px;
}
.task-square-msg {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-square-actions {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.task-time-ms {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(41, 182, 246, 0.09);
  color: #247b9b;
  font-family: ui-monospace, "JetBrains Mono", Consolas, monospace;
  font-size: 10.5px;
  letter-spacing: 0.01em;
}
.log-timeline {
  margin-top: 12px;
  max-height: 430px;
  overflow: auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: #0e1220;
  color: #dbe3f4;
  font-family: ui-monospace, "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
}
.log-line { display: flex; gap: 10px; padding: 2px 0; }
.log-line + .log-line { border-top: 1px solid rgba(255, 255, 255, 0.045); }
.log-time {
  flex: 0 0 178px;
  color: #73d5ff;
  white-space: nowrap;
}
.log-msg { color: #dbe3f4; word-break: break-word; white-space: pre-wrap; }
.log-time-empty { color: #5f6b85; }
@media (max-width: 700px) {
  .task-square-grid { grid-template-columns: 1fr; }
  .task-square { aspect-ratio: auto; min-height: 220px; }
}

/* ---------- large icon dashboard ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.dash-tile {
  position: relative;
  min-height: 180px;
  padding: 22px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.dash-tile::after {
  content: "";
  position: absolute;
  right: -28px;
  bottom: -50px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(246, 93, 142, 0.14), transparent 68%);
}
.dash-tile:hover {
  transform: translateY(-3px);
  border-color: #f3b7c9;
  box-shadow: 0 24px 42px -26px rgba(30, 41, 80, 0.4);
}
.dash-icon {
  width: 58px;
  height: 58px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand-grad);
  box-shadow: 0 14px 26px -16px rgba(246, 93, 142, 0.9);
  margin-bottom: 16px;
}
.dash-icon svg { width: 27px; height: 27px; }
.dash-tile h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.dash-tile p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.dash-meta { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 7px; }
.dash-meta span {
  font-size: 11.5px;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.dash-tile.accent-cyan .dash-icon { background: linear-gradient(135deg, #55d6f5, #2bb6e8); }
.dash-tile.accent-violet .dash-icon { background: linear-gradient(135deg, #9b8cff, #7867ef); }
.dash-tile.accent-green .dash-icon { background: linear-gradient(135deg, #59d7a7, #23a97e); }
.dash-tile.accent-amber .dash-icon { background: linear-gradient(135deg, #ffc266, #f09a2e); }
.dash-tile.accent-dark .dash-icon { background: linear-gradient(135deg, #3a4058, #1d2233); }
.dash-tile.dash-wide { grid-column: span 2; }

/* ---------- analytics KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.kpi {
  padding: 16px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.kpi .kpi-label { color: var(--faint); font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; }
.kpi .kpi-value { margin-top: 8px; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.kpi .kpi-sub { margin-top: 4px; color: var(--muted); font-size: 12px; }
.kpi.ok .kpi-value { color: var(--ok); }
.kpi.err .kpi-value { color: var(--err); }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.run .kpi-value { color: #d93a72; }
.kpi-bar { height: 5px; border-radius: 999px; background: #e9ecf5; overflow: hidden; margin-top: 10px; }
.kpi-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--brand-grad); }

@media (max-width: 980px) {
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-tile.dash-wide { grid-column: auto; }
}
@media (max-width: 620px) {
  .dashboard-grid, .kpi-grid { grid-template-columns: 1fr; }
}

/* ---------- admin tabs ---------- */
.admin-tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.admin-tab-btn {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.admin-tab-btn:hover { color: var(--text); background: rgba(246, 93, 142, 0.08); }
.admin-tab-btn.active {
  color: var(--text);
  background: #fff;
  box-shadow: 0 8px 18px -14px rgba(16, 24, 40, 0.55);
}
.admin-tab[hidden] { display: none !important; }
.pool-summary {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.account-proxies .check-item { margin: 2px 4px 2px 0; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 24px; box-shadow: 0 30px 70px -40px rgba(20, 28, 50, 0.5); padding: 30px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.login-card .sub { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 20px; }
.login-card .field { margin-bottom: 14px; }
.login-foot { margin-top: 16px; font-size: 12px; color: var(--faint); text-align: center; line-height: 1.7; }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { padding: 11px 14px; border-radius: 12px; background: #1c2233; color: #fff; font-size: 13px; box-shadow: 0 16px 34px -16px rgba(0, 0, 0, 0.5); max-width: 360px; }
.toast.err { background: #b3262b; }
.toast.ok { background: #0f7a57; }

@media (max-width: 820px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; }
  .layout { width: calc(100% - 20px); margin-top: 14px; }
  .hero { padding: 22px; }
  .card { padding: 16px; border-radius: 16px; }
  .brand-sub { display: none; }
  .kv { grid-template-columns: 88px 1fr; }
}
