:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #657085;
  --line: #dfe4ec;
  --sidebar: #18212f;
  --sidebar-soft: #253144;
  --blue: #2468d8;
  --blue-soft: #e7f0ff;
  --green: #168356;
  --green-soft: #e5f5ed;
  --amber: #a96508;
  --amber-soft: #fff3dc;
  --red: #bd3434;
  --red-soft: #fdeaea;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f7;
}
.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(23, 32, 51, 0.12);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 24px;
}
.login-brand .brand-mark { flex: 0 0 auto; }
.login-title { margin: 0; font-size: 20px; line-height: 1.3; }
.login-subtitle { margin-top: 3px; color: var(--muted); font-size: 12px; }
.login-form { display: grid; gap: 15px; }
.login-form label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.login-form input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}
.login-form input:focus { border-color: #7ba7ea; box-shadow: 0 0 0 3px rgba(36, 104, 216, 0.11); }
.login-form .btn { min-height: 42px; width: 100%; }
.login-error { min-height: 20px; margin: 0; color: var(--red); font-size: 12px; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  color: #d7deea;
  background: var(--sidebar);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  color: #fff;
  font-size: 17px;
  font-weight: 750;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #4e6382;
  border-radius: 7px;
  background: #26364d;
  color: #dbe8ff;
  font-size: 12px;
  font-weight: 800;
}
.nav-label {
  margin: 12px 10px 7px;
  color: #8fa0b8;
  font-size: 11px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin: 3px 0;
  padding: 9px 11px;
  border-radius: 7px;
  color: #cdd6e4;
  text-decoration: none;
}
.nav a:hover, .nav a.active { color: #fff; background: var(--sidebar-soft); }
.nav-icon {
  width: 22px;
  color: #8fb8ff;
  text-align: center;
  font-weight: 800;
}
.sidebar-foot {
  position: absolute;
  right: 14px;
  bottom: 18px;
  left: 14px;
  padding: 11px;
  border: 1px solid #34445b;
  border-radius: 7px;
  color: #aebbd0;
  background: #202c3d;
  font-size: 12px;
}
.sidebar-foot strong { display: block; margin-top: 3px; color: #fff; }

.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}
.page-title { font-size: 19px; font-weight: 760; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.top-user { max-width: 160px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.content { width: 100%; max-width: 1500px; padding: 22px 26px 36px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.metric, .panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.metric { min-height: 104px; padding: 15px; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 7px; font-size: 24px; font-weight: 780; }
.metric-note { margin-top: 3px; color: var(--muted); font-size: 12px; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(330px, 0.65fr);
  gap: 16px;
  align-items: start;
}
.panel { overflow: hidden; }
.panel-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-title { font-size: 15px; font-weight: 750; }
.panel-sub { margin-top: 2px; color: var(--muted); font-size: 12px; }
.panel-body { padding: 16px; }

.btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #fff;
  white-space: nowrap;
}
.btn:hover { border-color: #98b7e9; color: var(--blue); }
.btn.primary { color: #fff; border-color: var(--blue); background: var(--blue); }
.btn.soft { border-color: #cddcf4; color: #24579f; background: #f2f7ff; }
.btn.danger { border-color: #e8bcbc; color: var(--red); background: #fff7f7; }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.green { color: #126843; background: var(--green-soft); }
.badge.amber { color: #865004; background: var(--amber-soft); }
.badge.red { color: #972727; background: var(--red-soft); }
.badge.blue { color: #245ba8; background: var(--blue-soft); }
.badge.gray { color: #596579; background: #edf0f4; }

.table-wrap { overflow: auto; }
table { width: 100%; min-width: 800px; border-collapse: collapse; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--panel-soft); font-size: 12px; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.name { font-weight: 730; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.actions { display: flex; align-items: center; gap: 7px; }
.metric-input { width: 86px; min-height: 34px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; }
.progress {
  width: 150px;
  height: 7px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 4px;
  background: #e9edf3;
}
.progress span { display: block; height: 100%; background: var(--blue); }
.stop-points { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.stop-point { padding: 2px 6px; border: 1px solid #d9e1ec; border-radius: 5px; color: #556276; background: #f8fafc; font-size: 11px; }

.form { display: grid; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.field label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.field input, .field select {
  width: 100%;
  min-height: 38px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #fff;
}
.field input:focus, .field select:focus { border-color: #7ba7ea; box-shadow: 0 0 0 3px rgba(36, 104, 216, 0.11); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 2px; }

.empty { padding: 34px 18px; color: var(--muted); text-align: center; }
.runtime-grid { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 14px; }
.runtime-item { min-height: 94px; padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.runtime-item span { color: var(--muted); font-size: 12px; }
.runtime-item strong { display: block; margin-top: 9px; font-size: 16px; }
.endpoint { margin-top: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-soft); overflow-wrap: anywhere; }

.subject-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.55fr); gap: 16px; align-items: start; }
.subject-list { display: grid; gap: 12px; padding: 14px; }
.subject-card { padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.subject-card-head, .subject-actions, .control-token-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.subject-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.account-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.account-chip { display: inline-flex; flex-direction: column; gap: 1px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-soft); font-size: 12px; }
.account-chip b { font-weight: 650; }
.subject-actions { justify-content: flex-start; margin-top: 13px; }
.notice { margin-top: 10px; padding: 9px 10px; border-radius: 6px; font-size: 12px; }
.error-notice { border-left: 3px solid var(--red); color: #872828; background: var(--red-soft); }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 44px));
  padding: 11px 14px;
  border-radius: 7px;
  color: #fff;
  background: #1d2939;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 0.18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #a32e2e; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .layout { grid-template-columns: 1fr; }
  .subject-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 10px 12px; }
  .brand { padding: 2px 4px 10px; }
  .nav-label, .sidebar-foot { display: none; }
  .nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .nav a { justify-content: center; margin: 0; padding: 7px 5px; font-size: 12px; }
  .nav-icon { display: none; }
  .topbar { position: static; height: 58px; padding: 0 14px; }
  .page-title { font-size: 16px; }
  .top-user { display: none; }
  .top-actions { gap: 6px; }
  .top-actions .btn { min-width: 44px; padding: 7px 9px; }
  .content { padding: 14px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric { min-height: 88px; padding: 12px; }
  .metric-value { font-size: 20px; }
  .form-grid, .runtime-grid { grid-template-columns: 1fr; }
  .login-shell { padding: 14px; }
  .login-panel { padding: 22px 18px; }
}
