:root {
  --bg: #eef3fb;
  --panel: #ffffff;
  --panel-soft: #f7f9fe;
  --line: #d8e1f2;
  --text: #22324a;
  --muted: #6f7f96;
  --blue-700: #1f3e9a;
  --blue-600: #2b57d9;
  --blue-500: #3c6ff8;
  --blue-100: #e7efff;
  --danger: #d32f2f;
  --warning: #f59e0b;
  --success: #1a9a57;
  --shadow-sm: 0 4px 10px rgba(31, 62, 154, 0.08);
  --shadow-md: 0 10px 24px rgba(31, 62, 154, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "HarmonyOS Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  background: linear-gradient(170deg, #1b3492 0%, #1c3a9e 46%, #1d47b3 100%);
  color: #dbe6ff;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-text strong {
  font-size: 14px;
}

.brand-text span {
  font-size: 11px;
  opacity: 0.76;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #c9d8ff;
  padding: 10px 12px;
  text-align: left;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: #d0ddff;
}

.workspace {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.topbar h1 {
  margin: 0 0 4px;
  color: #16327f;
  font-size: 22px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.account-actions {
  justify-content: flex-end;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: #f0f5ff;
  border: 1px solid #ccdaf8;
  color: #1d3f9f;
  font-size: 12px;
  font-weight: 700;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  background: linear-gradient(140deg, #ffffff, #f7faff);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.stat-card strong {
  color: #1d3f9f;
  font-size: 26px;
  line-height: 1;
}

.auth-card,
.panel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.auth-card h2,
.panel-card h2 {
  margin: 0 0 10px;
  color: #18397d;
  font-size: 16px;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #617693;
  font-size: 12px;
}

label.full {
  grid-column: 1 / -1;
}

.inline-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

input,
textarea,
select {
  border: 1px solid #c7d3ea;
  border-radius: 9px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(60, 111, 248, 0.15);
}

textarea {
  resize: vertical;
}

button {
  border: 1px solid #c4d0e9;
  border-radius: 9px;
  background: #ffffff;
  color: #2a4263;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

button:hover {
  border-color: var(--blue-500);
  color: var(--blue-600);
}

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

button.primary {
  border-color: var(--blue-600);
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  color: #ffffff;
}

button.primary:hover {
  border-color: #2450cb;
  color: #ffffff;
}

button.warning {
  border-color: #f8de9d;
  background: #fff9ea;
  color: #9a6407;
}

button.warning:hover {
  border-color: #f4c768;
  color: #8a5702;
}

button.danger {
  border-color: #f5c4c4;
  background: #fff4f4;
  color: #b42323;
}

button.danger:hover {
  border-color: #e89f9f;
  color: #9f1f1f;
}

button.ghost {
  background: transparent;
}

form button[type="submit"] {
  grid-column: 1 / -1;
}

.secondary-action {
  grid-column: 1 / -1;
  justify-self: start;
}

.panel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.remote-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr) auto auto;
  gap: 8px;
  margin: 10px 0;
}

.ops-meta,
.ops-result {
  color: var(--muted);
  background: #f7faff;
  border: 1px solid #dfe8f7;
  border-radius: 10px;
  padding: 10px;
  margin: 10px 0;
  white-space: pre-wrap;
}

.ops-result ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.ops-result li.ok {
  color: #157347;
}

.ops-result li.warning {
  color: #9a6407;
}

.ops-result li.risk {
  color: #b42323;
}

.risk-score {
  font-weight: 800;
}

.risk-score.low {
  color: #157347;
}

.risk-score.medium {
  color: #9a6407;
}

.risk-score.high {
  color: #b42323;
}

.remote-screen-wrap {
  min-height: 260px;
  background:
    linear-gradient(45deg, rgba(31, 62, 154, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(31, 62, 154, 0.05) 25%, transparent 25%),
    #f6f8fd;
  background-size: 18px 18px;
  border: 1px solid #dfe8f7;
  border-radius: 12px;
  overflow: auto;
  display: grid;
  place-items: center;
}

.remote-screen {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  cursor: crosshair;
}

.full-select {
  width: 100%;
  margin: 10px 0;
}

.helper-text {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.permission-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.permission-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-soft);
}

.permission-group h3 {
  margin: 0 0 8px;
  color: #18397d;
  font-size: 13px;
}

.permission-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 4px 8px;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}

.permission-option input {
  width: 16px;
  height: 16px;
}

.permission-option small {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
}

.ops-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 12px;
  padding: 18px;
  border: 1px solid #cdd9f0;
  border-radius: 16px;
  background:
    radial-gradient(circle at 10% 10%, rgba(60, 111, 248, 0.18), transparent 28%),
    linear-gradient(135deg, #ffffff 0%, #f2f7ff 100%);
  box-shadow: var(--shadow-sm);
}

.ops-hero.cookie-hero {
  background:
    radial-gradient(circle at 10% 10%, rgba(26, 154, 87, 0.14), transparent 28%),
    linear-gradient(135deg, #ffffff 0%, #f4fbf7 100%);
}

.ops-hero.agent-hero {
  background:
    radial-gradient(circle at 85% 20%, rgba(245, 158, 11, 0.16), transparent 30%),
    linear-gradient(135deg, #ffffff 0%, #fff8ec 100%);
}

.ops-hero h2 {
  margin: 4px 0 6px;
  color: #17377d;
  font-size: 22px;
}

.ops-hero p {
  margin: 0;
  max-width: 780px;
  color: #5d718c;
  line-height: 1.7;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: #e7efff;
  color: #1f3e9a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.remote-layout,
.rpa-layout,
.agent-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
}

.agent-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  margin-bottom: 12px;
}

.agent-command-box,
.agent-note {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #d8e1f2;
  border-radius: 12px;
  background: #f8fbff;
}

.agent-command-box code {
  display: block;
  padding: 10px;
  border-radius: 8px;
  background: #16254a;
  color: #e7efff;
  white-space: pre-wrap;
  word-break: break-all;
}

.agent-note span,
.agent-command-box p,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.rpa-layout {
  grid-template-columns: 430px minmax(0, 1fr);
}

.remote-stage-card,
.remote-control-card,
.wide-card {
  min-width: 0;
}

.toolbar-select {
  min-width: 260px;
}

.remote-screen-wrap.large {
  min-height: 560px;
}

.cookie-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.cookie-summary-card {
  background: #ffffff;
  border: 1px solid #dce6f7;
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.cookie-summary-card strong {
  display: block;
  color: #18397d;
  font-size: 15px;
  margin-bottom: 8px;
}

.cookie-summary-card span {
  display: block;
  color: #5f7291;
  font-size: 12px;
  line-height: 1.7;
}

.step-builder {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.window-filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-btn {
  background: #f4f7ff;
  border-color: #d7e2f5;
}

.filter-btn.active {
  background: var(--blue-100);
  color: #1f3e9a;
  border-color: #b7c9f2;
}

.view-stack {
  min-height: 0;
}

.view-panel {
  display: none;
}

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

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.triple-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 880px;
}

thead th {
  text-align: left;
  background: #f3f7ff;
  color: #5f7291;
  border-top: 1px solid #dce6f7;
  border-bottom: 1px solid #dce6f7;
  padding: 10px 8px;
  font-size: 12px;
  position: sticky;
  top: 0;
}

thead th:first-child {
  border-left: 1px solid #dce6f7;
  border-top-left-radius: 8px;
}

thead th:last-child {
  border-right: 1px solid #dce6f7;
  border-top-right-radius: 8px;
}

tbody td {
  padding: 10px 8px;
  border-bottom: 1px solid #edf2fb;
  font-size: 13px;
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: #fbfdff;
}

tbody tr:hover {
  background: #f5f8ff;
}

tbody tr.empty-row td {
  text-align: center;
  color: #7b8ba2;
  padding: 20px 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-badge.running {
  color: #0f7f49;
  background: #eafaf2;
  border-color: #b9ebcf;
}

.status-badge.online,
.status-badge.success {
  color: #0f7f49;
  background: #eafaf2;
  border-color: #b9ebcf;
}

.status-badge.approved {
  color: #0f7f49;
  background: #eafaf2;
  border-color: #b9ebcf;
}

.status-badge.pending {
  color: #9a6407;
  background: #fff9ea;
  border-color: #f8de9d;
}

.status-badge.queued {
  color: #9a6407;
  background: #fff9ea;
  border-color: #f8de9d;
}

.status-badge.rejected {
  color: #ab1d1d;
  background: #fff1f1;
  border-color: #efc8c8;
}

.status-badge.stopped,
.status-badge.idle,
.status-badge.offline {
  color: #5c6f89;
  background: #f2f6fc;
  border-color: #d7e0ed;
}

.status-badge.failed {
  color: #ab1d1d;
  background: #fff1f1;
  border-color: #efc8c8;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
}

.drawer.show {
  display: block;
}

.drawer-mask {
  position: absolute;
  inset: 0;
  background: rgba(9, 20, 47, 0.48);
}

.drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(860px, 96vw);
  background: #ffffff;
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 24px rgba(9, 20, 47, 0.2);
  display: flex;
  flex-direction: column;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5ecf9;
}

.drawer-header h2 {
  margin: 0 0 4px;
  color: #14347f;
}

.drawer-header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.mode-label {
  display: inline-flex;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf3ff;
  border: 1px solid #cbd9f5;
  color: #24489a;
  font-size: 12px;
  font-weight: 600;
}

.effect-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 16px 0;
}

.effect-chip,
.field-effect-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.effect-chip {
  padding: 4px 8px;
}

.field-effect-badge {
  margin-top: 4px;
  align-self: flex-start;
  padding: 3px 8px;
}

.inline-check .field-effect-badge {
  margin-top: 0;
  margin-left: auto;
}

.effect-context {
  color: #0f5a9a;
  background: #e8f2ff;
  border-color: #bfd8ff;
}

.effect-arg {
  color: #1b5c3b;
  background: #e9f8ef;
  border-color: #bfe6cd;
}

.effect-script {
  color: #724c0f;
  background: #fff7e5;
  border-color: #f5deb4;
}

.effect-flow {
  color: #5d457f;
  background: #f4edff;
  border-color: #dccaef;
}

.effect-store {
  color: #5c6f89;
  background: #f3f6fb;
  border-color: #d9e2f0;
}

.preset-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px dashed #cad8f2;
  border-radius: 10px;
  background: #f7faff;
}

.preset-toolbar-title {
  color: #526a8b;
  font-size: 12px;
  font-weight: 600;
}

.field-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.link-btn {
  border: 0;
  background: transparent;
  color: #2955a1;
  padding: 0;
  font-weight: 600;
}

.link-btn:hover {
  border: 0;
  color: #1f3e9a;
  text-decoration: underline;
}

.url-builder {
  gap: 8px;
}

.url-builder-title {
  color: #617693;
  font-size: 12px;
}

.url-builder-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.url-tag-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.url-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #cfe0f8;
  background: #edf4ff;
  color: #20458f;
  font-size: 12px;
  max-width: 100%;
}

.url-tag-text {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.url-tag button {
  border: 0;
  background: transparent;
  color: #7a90b3;
  padding: 0;
  font-size: 13px;
  line-height: 1;
}

.url-tag button:hover {
  border: 0;
  color: #d32f2f;
}

.url-builder-hint {
  color: #8294ad;
  font-size: 12px;
}

.drawer-panel form {
  padding: 14px 16px 18px;
  overflow: auto;
  grid-template-columns: 1fr;
  gap: 12px;
}

.drawer-section {
  border: 1px solid #e4ebf8;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.drawer-section h3 {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  font-size: 14px;
  color: #20458f;
}

.drawer-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.drawer-footer > :first-child {
  margin-right: auto;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: none;
}

.modal.show {
  display: block;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(9, 20, 47, 0.48);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(560px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  background: #ffffff;
  border: 1px solid #dce5f4;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(9, 20, 47, 0.24);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px;
  background: linear-gradient(135deg, #f9fbff, #edf4ff);
  border-bottom: 1px solid #e4ebf8;
}

.modal-header h2 {
  margin: 0 0 4px;
  color: #14347f;
  font-size: 18px;
}

.modal-header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.account-form {
  padding: 18px 20px 20px;
  grid-template-columns: 1fr;
}

.account-form button[type="submit"] {
  margin-top: 4px;
}

.progress-panel {
  width: min(520px, calc(100vw - 32px));
}

.progress-body {
  display: grid;
  gap: 12px;
  padding: 18px 20px 20px;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: #e8eef8;
  overflow: hidden;
  border: 1px solid #d8e2f2;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f65df, #18a058);
  transition: width 0.2s ease;
}

.progress-track span.is-error {
  background: linear-gradient(90deg, #d96b1d, #d43b3b);
}

.progress-body p {
  margin: 0;
  color: #365274;
  font-size: 13px;
}

.security-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #dfe8f7;
  border-radius: 12px;
  background: #f8fbff;
}

.security-box strong {
  color: #14347f;
}

.security-box span {
  color: var(--muted);
  font-size: 12px;
}

.hidden {
  display: none;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  background: #102954;
  color: #e9f1ff;
  border: 1px solid #2955a1;
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 420px;
  display: none;
  z-index: 1100;
  box-shadow: 0 12px 24px rgba(16, 41, 84, 0.28);
}

.toast.show {
  display: block;
}

@media (max-width: 1200px) {
  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .two-col,
  .agent-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .compact-form,
  form,
  .drawer-section,
  .triple-grid,
  .remote-layout,
  .rpa-layout,
  .agent-grid,
  .cookie-summary-grid,
  .step-builder,
  .remote-toolbar {
    grid-template-columns: 1fr;
  }

  .ops-hero {
    flex-direction: column;
  }
}
