:root {
  color-scheme: light;
  --bg: #f4f8ff;
  --panel: #ffffff;
  --panel-soft: #eaf2ff;
  --border: #d7e4fb;
  --text: #13304f;
  --muted: #6c819d;
  --blue: #2563eb;
  --blue-2: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 16px 40px rgba(29, 78, 216, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #f7faff 0%, #eef4ff 100%);
  color: var(--text);
}

a { color: var(--blue); text-decoration: none; }
button, input { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 22px;
  background: rgba(255,255,255,0.88);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue), #60a5fa);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.brand h1 { font-size: 18px; margin: 0; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.nav-tabs { display: grid; gap: 10px; padding: 16px 0; }
.tab {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.rpa-nav {
  position: relative;
  display: grid;
  gap: 3px;
  align-content: center;
  min-height: 54px;
  padding-right: 64px;
}
.rpa-nav strong {
  position: absolute;
  top: 7px;
  right: 8px;
  min-width: 42px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--blue-2);
  text-align: center;
  font-size: 12px;
  line-height: 1;
}
.rpa-nav.on {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
.rpa-nav.off {
  background: #fff5f5;
  color: #b91c1c;
  border-color: #fecaca;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .08);
}
.rpa-nav.off strong {
  color: #b91c1c;
  background: #fee2e2;
}

.side-panel { display: grid; gap: 16px; }
.folder-item, .panel {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 12px;
}

.folder-list { display: grid; gap: 10px; }
.folder-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  color: var(--text);
}
.folder-link {
  min-width: 0;
  display: grid;
  gap: 4px;
  color: var(--text);
}
.folder-item.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.folder-item em { color: var(--muted); font-style: normal; font-size: 12px; }
.folder-delete {
  padding: 7px 10px;
  border-radius: 8px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  color: #b91c1c;
}
.folder-delete:hover { background: #fee2e2; }
.folder-empty {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
}
.folder-empty button,
.create-folder-pill {
  background: #eaf2ff;
  color: var(--blue-2);
  border: 1px solid #93c5fd;
}
.create-folder-pill {
  cursor: pointer;
}

.main { padding: 26px; }
.view { display: none; }
.view.active { display: block; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}
.topbar h2 { margin: 0; font-size: 28px; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--blue-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.toolbar-actions { display: flex; gap: 10px; }
.outline-btn {
  background: #fff;
  color: var(--blue);
  border: 1px solid var(--border);
}
.outline-btn:hover { background: var(--panel-soft); }

.panel { padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.upload-form, .link-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}
.link-form { grid-template-columns: 1fr 1.2fr auto; }
input[type="file"], input[type="text"], input[type="url"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
input[type="file"] {
  min-height: 48px;
  color: var(--muted);
  background: #f8fbff;
  border-color: #c8d9f5;
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 9px 13px;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  background: #eaf2ff;
  color: var(--blue-2);
  font-weight: 600;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover {
  background: #dbeafe;
}
button {
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  padding: 12px 16px;
  cursor: pointer;
}
button:hover { background: var(--blue-2); }
button:disabled {
  cursor: wait;
  opacity: .72;
}
#uploadSubmitBtn {
  min-width: 124px;
  border: 1px solid var(--blue-2);
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
  box-shadow: 0 8px 18px rgba(37, 99, 235, .2);
  font-weight: 700;
}
#uploadSubmitBtn:hover {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .28);
}
#uploadSubmitBtn:disabled {
  background: #93c5fd;
  border-color: #93c5fd;
  box-shadow: none;
}
.hint { color: var(--muted); font-size: 13px; }

.table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.table-head h3 { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
.url-cell { max-width: 360px; word-break: break-all; }
.actions { display: flex; gap: 8px; }
.ghost-btn {
  background: transparent;
  color: var(--blue);
  border: 1px solid var(--border);
  padding: 8px 12px;
}
.ghost-btn.danger { color: var(--danger); }

.modal-layer {
  position: fixed;
  inset: 0;
  background: rgba(12, 29, 54, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}
.child-modal-layer {
  background: rgba(12, 29, 54, 0.22);
  z-index: 70;
}
.modal-card {
  width: min(920px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 28px 80px rgba(19, 48, 79, 0.22);
}
.child-modal-card {
  width: min(680px, 100%);
}
.modal-head, .modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-foot {
  border-bottom: 0;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.modal-body { padding: 18px; display: grid; gap: 14px; }
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 0;
}
.hidden { display: none !important; }

.modal-grid { display: grid; gap: 12px; }
.modal-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.modal-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rpa-state-banner {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.rpa-state-banner span { color: var(--muted); font-size: 13px; }
.rpa-state-banner strong { font-size: 22px; }
.rpa-state-banner em { justify-self: end; font-style: normal; font-size: 13px; }
.auth-config-btn {
  justify-self: end;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #fecaca;
  background: #fff;
  color: #b91c1c;
  font-size: 13px;
}
.auth-config-btn.ready {
  border-color: #93c5fd;
  color: var(--blue-2);
}
.rpa-state-banner.on {
  background: #eaf2ff;
  border-color: #93c5fd;
  color: var(--blue-2);
}
.rpa-state-banner.off {
  background: #fff5f5;
  border-color: #fecaca;
  color: #b91c1c;
}
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
input[type="password"],
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.rpa-control-card {
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 10px 24px rgba(29, 78, 216, 0.06);
}
.rpa-control-card label {
  font-weight: 700;
  color: var(--text);
}
.number-shell,
.select-shell {
  min-height: 48px;
  display: grid;
  align-items: center;
  border: 1px solid #c8d9f5;
  border-radius: 12px;
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.number-shell {
  grid-template-columns: 1fr auto;
  overflow: hidden;
}
.number-shell input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 12px 14px;
  color: var(--text);
  background: transparent;
  font-size: 18px;
  font-weight: 700;
}
.number-shell span {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 0 14px;
  color: var(--blue-2);
  background: var(--panel-soft);
  border-left: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}
.select-shell {
  position: relative;
}
.select-shell::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--blue);
  border-bottom: 2px solid var(--blue);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
.select-shell select {
  width: 100%;
  min-height: 48px;
  appearance: none;
  border: 0;
  outline: 0;
  border-radius: 12px;
  padding: 12px 42px 12px 14px;
  color: var(--text);
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.number-shell:focus-within,
.select-shell:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
  background: #fbfdff;
}
.number-shell:hover,
.select-shell:hover {
  border-color: #93c5fd;
}
.field textarea {
  min-height: 120px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font: inherit;
}
.modal-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.auth-token-preview {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fff5f5;
  color: #b91c1c;
}
.auth-token-preview.ready {
  border-color: #93c5fd;
  background: #eaf2ff;
  color: var(--blue-2);
}
.auth-token-preview span,
.auth-token-preview em {
  font-size: 13px;
}
.auth-token-preview strong {
  word-break: break-all;
  font-size: 14px;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.toast-wrap {
  position: fixed;
  right: 18px;
  top: 18px;
  display: grid;
  gap: 10px;
  z-index: 60;
}
.toast {
  min-width: 260px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.toast.ok { border-color: rgba(37, 99, 235, 0.35); }
.toast.err { border-color: rgba(220, 38, 38, 0.35); }
.toast .title { font-weight: 600; margin-bottom: 4px; }
.toast .desc { color: var(--muted); font-size: 13px; word-break: break-word; }

.form-row { display: grid; gap: 12px; }
.form-row input, .form-row select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.input-with-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.input-with-button input { min-width: 0; }
.codebox {
  width: 100%;
  min-height: 150px;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  font: inherit;
  font-family: Consolas, Monaco, monospace;
  resize: vertical;
}
.result-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 13px;
}
.result-meta span {
  min-width: 0;
  word-break: break-all;
}
.json-view {
  max-height: 58vh;
  margin: 0;
  background: #0f172a;
  color: #dbeafe;
  border-color: #1e3a8a;
}
.json-view code {
  font-size: 13px;
  line-height: 1.65;
  white-space: pre;
}
.json-key { color: #93c5fd; }
.json-string { color: #bbf7d0; }
.json-number { color: #fde68a; }
.json-boolean { color: #fca5a5; }
.json-null { color: #c4b5fd; }

.docs-panel { display: grid; gap: 18px; }
.docs-panel article { padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.docs-panel article:last-child { border-bottom: 0; padding-bottom: 0; }
pre {
  margin: 10px 0;
  padding: 14px;
  background: #f8fbff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
}
code { font-family: Consolas, Monaco, monospace; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .upload-form, .link-form { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .modal-grid.two, .modal-grid.three { grid-template-columns: 1fr; }
  .rpa-state-banner { grid-template-columns: 1fr; }
  .rpa-state-banner em { justify-self: start; }
  .auth-config-btn { justify-self: start; }
  .input-with-button { grid-template-columns: 1fr; }
  .result-meta { grid-template-columns: 1fr; }
}
