:root {
  --bg1: #151515;
  --bg2: #2b2b2b;
  --panel: #1b1b1b;
  --panel-2: #222;
  --text: #f2f2f2;
  --muted: #bfbfbf;
  --accent: #e24b4b;
  --accent-soft: #ff7a7a;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.45);
  --font: "Poppins", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 8% 0%, #3a1414 0%, transparent 60%),
    radial-gradient(900px 500px at 92% 12%, #421717 0%, transparent 65%),
    linear-gradient(140deg, var(--bg1), var(--bg2));
  min-height: 100vh;
}

.bg::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='140' height='140' viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 70h140M70 0v140' stroke='rgba(255,255,255,0.04)' stroke-width='1'/%3E%3C/svg%3E");
  opacity: 0.6;
  pointer-events: none;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 36px 16px;
}

.card {
  width: min(520px, 92vw);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px var(--shadow);
  backdrop-filter: blur(10px);
}

.guide-card {
  width: 100%;
  max-width: 760px;
  padding: 28px 24px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brand .logo {
  font-size: 28px;
  letter-spacing: 3px;
  font-weight: 600;
  color: var(--accent-soft);
}

.brand .subtitle {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
}

h1,
h2 {
  margin: 12px 0 8px;
  font-weight: 600;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 16px;
}

p {
  margin: 8px 0 20px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

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

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(18, 18, 18, 0.8);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0px 1000px rgba(18, 18, 18, 0.95) inset;
  transition: background-color 5000s ease-in-out 0s;
}

.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

.btn.primary {
  background: #e24b4b;
  border: none;
  color: #fff;
  font-weight: 600;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
}

.error {
  margin-top: 12px;
  color: #ffb3b3;
  min-height: 18px;
  font-size: 14px;
}

.hint {
  margin-top: 20px;
  font-size: 12px;
  color: var(--muted);
}

.topbar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 20, 20, 0.75);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 2;
}

.topbar-note {
  position: absolute;
  right: 20px;
  bottom: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.2px;
  pointer-events: none;
}

.brand.mini .logo {
  font-size: 22px;
}

.keybox {
  display: flex;
  gap: 16px;
  align-items: center;
}

.key-meta {
  text-align: right;
}

.key-meta .label {
  font-size: 12px;
  color: var(--muted);
}

.key-meta .value {
  font-size: 14px;
}

.layout {
  padding: 20px 20px 48px;
  display: grid;
  gap: 14px;
  max-width: 1080px;
  margin: 0 auto;
}

.panel {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 40px var(--shadow);
}

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

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn.small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.panel.compact {
  padding: 10px 14px;
}

.info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 6px;
}

.info-item {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.info-item .value {
  color: var(--text);
  font-weight: 600;
}

.panel.tight {
  padding: 12px 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.stat {
  padding: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
}

.stat .value {
  font-size: 18px;
  margin-top: 6px;
}

.search {
  margin-top: 8px;
  display: grid;
  gap: 10px;
}

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

.field label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.field-tools {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.toolbox {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hint-btn {
  position: relative;
}

.hint-btn:hover .tooltip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.tooltip {
  position: absolute;
  right: 0;
  top: 36px;
  width: 240px;
  background: rgba(10, 5, 5, 0.92);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
  opacity: 0;
  transform: translateY(-6px);
  transition: all 0.2s ease;
  pointer-events: none;
  box-shadow: 0 10px 30px var(--shadow);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  max-height: 360px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  border: 1px solid var(--border);
}

thead {
  background: rgba(255, 255, 255, 0.05);
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.06);
  white-space: normal;
  word-break: break-all;
  vertical-align: top;
}

th {
  white-space: nowrap;
}

.panel-title-with-tip {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.result-copy-tip {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.58);
}

.copy-col-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  color: rgba(255, 255, 255, 0.9);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.copy-col-trigger::after {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(226, 75, 75, 0.7);
  box-shadow: 0 0 10px rgba(226, 75, 75, 0.28);
}

.copy-col-trigger:hover {
  color: #fff5f5;
  border-color: rgba(226, 75, 75, 0.3);
  background:
    linear-gradient(180deg, rgba(226, 75, 75, 0.16), rgba(255, 255, 255, 0.03));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

.copy-col-trigger:focus-visible {
  outline: none;
  border-color: rgba(255, 122, 122, 0.5);
  box-shadow: 0 0 0 3px rgba(226, 75, 75, 0.16);
}

.copy-col-trigger:active {
  transform: translateY(0);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.result-panel {
  min-height: 420px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.pagination .page-size {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.pagination .page-size select,
.pagination .page-jump input {
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

.pagination .page-size select {
  appearance: auto;
  min-width: 88px;
}

.pagination .page-size select option {
  color: #111;
}

.pagination .page-jump {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.pagination .page-jump input {
  width: 88px;
}

.pagination .page-info {
  font-size: 12px;
  color: var(--muted);
}

.hidden {
  display: none;
}

.expiry-warning {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  color: #ffd6d6;
  background: rgba(226, 75, 75, 0.18);
  border: 1px solid rgba(226, 75, 75, 0.35);
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .keybox {
    width: 100%;
    justify-content: space-between;
  }

  .pagination {
    justify-content: flex-start;
  }

  .guide-card {
    padding: 22px 18px;
  }
}

.ai-textarea {
  width: 100%;
  min-height: 130px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(18, 18, 18, 0.8);
  color: var(--text);
  font-size: 14px;
  outline: none;
  resize: vertical;
}

.ai-result {
  margin-top: 12px;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.ai-result code {
  color: #ffd6d6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.task-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
}

.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task-status {
  flex: 0 0 auto;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: #d5d5d5;
  background: rgba(255, 255, 255, 0.04);
}

.task-status.done {
  color: #9ee4b7;
  border-color: rgba(105, 196, 140, 0.5);
}

.task-status.running {
  color: #ffd7a6;
  border-color: rgba(240, 176, 94, 0.55);
}

.task-status.failed {
  color: #ffb6b6;
  border-color: rgba(226, 96, 96, 0.55);
}

.task-item:hover {
  border-color: rgba(226, 75, 75, 0.5);
}

.kami-login-card {
  width: min(720px, 94vw);
  margin: 48px auto;
  padding: 24px 20px;
}

.kami-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
}

.kami-modal.hidden {
  display: none !important;
}

.kami-modal-card {
  width: min(680px, 96vw);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  box-shadow: 0 20px 60px var(--shadow);
  padding: 16px;
}

.ai-result pre {
  margin: 6px 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12px;
  color: #ffd6d6;
}

.graph-shell {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  padding: 8px;
}

#graph-canvas {
  width: 100%;
  height: 320px;
  display: block;
}

.ai-status {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.24);
  min-height: 80px;
}

.status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.status-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.status-list .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  background: rgba(255, 255, 255, 0.35);
}

.status-list li.pending .txt {
  color: var(--muted);
}

.status-list li.running .dot {
  background: #ffb4b4;
  box-shadow: 0 0 0 4px rgba(255, 122, 122, 0.2);
}

.status-list li.running .txt {
  color: #ffe3e3;
}

.status-list li.done .dot {
  background: #84d8a8;
}

.status-list li.done .txt {
  color: #d9f3e5;
}

.status-list li.failed .dot {
  background: #ff6f6f;
}

.status-list li.failed .txt {
  color: #ffbcbc;
}

/* AI page: fixed module heights + inner scrolling */
.ai-page .panel-fixed {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: var(--panel-height, 340px);
}

.ai-page .panel-fixed .panel-head {
  flex: 0 0 auto;
}

.ai-page .panel-fixed > :not(.panel-head) {
  min-height: 0;
}

.ai-page .panel-fixed.compact {
  --panel-height: 108px;
}

.ai-page .panel-fixed.tight {
  --panel-height: 300px;
}

.ai-page .panel-fixed.result-panel {
  --panel-height: 420px;
}

.ai-page .panel-fixed.panel-task {
  --panel-height: 280px;
}

.ai-page .panel-fixed.panel-graph {
  --panel-height: 620px;
}

.ai-page .panel-fixed .info-row,
.ai-page .panel-fixed .search,
.ai-page .panel-fixed #ai-status,
.ai-page .panel-fixed .ai-result,
.ai-page .panel-fixed #task-list,
.ai-page .panel-fixed .graph-shell,
.ai-page .panel-fixed #graph-view {
  overflow: auto;
}

.ai-page .panel-fixed.tight .search {
  flex: 1 1 auto;
}

.ai-page .panel-fixed.result-panel #ai-status {
  flex: 0 0 120px;
}

.ai-page .panel-fixed.result-panel #ai-result {
  flex: 1 1 auto;
}

.ai-page .panel-fixed.panel-task #task-list {
  flex: 1 1 auto;
  margin-top: 10px;
}

.ai-page .panel-fixed.panel-graph .graph-shell {
  flex: 1 1 auto;
  min-height: 0;
}

.ai-page .panel-fixed.panel-graph #graph-view {
  flex: 0 0 130px;
  min-height: 0;
}

@media (max-width: 720px) {
  .ai-page .panel-fixed.compact {
    --panel-height: 120px;
  }

  .ai-page .panel-fixed.tight {
    --panel-height: 320px;
  }

  .ai-page .panel-fixed.result-panel {
    --panel-height: 420px;
  }

  .ai-page .panel-fixed.panel-task {
    --panel-height: 260px;
  }

  .ai-page .panel-fixed.panel-graph {
    --panel-height: 560px;
  }
}


.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}

.audit-table th,
.audit-table td {
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.audit-table th {
  color: #ffd7d7;
  background: rgba(226, 75, 75, 0.15);
}

.audit-table td {
  color: #f2dada;
  word-break: break-all;
}

@media (max-width: 720px) {
  .topbar-note {
    position: static;
    width: 100%;
    text-align: right;
    margin-top: 4px;
    font-size: 10px;
  }
}
