:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f4f2;
  --surface-3: #e9efec;
  --line: #dbe3df;
  --line-strong: #c4d0cb;
  --text: #1e292d;
  --muted: #66767c;
  --subtle: #8a989e;
  --green: #14835f;
  --green-dark: #0f6048;
  --green-soft: #e4f4ee;
  --blue: #2d65d8;
  --blue-soft: #eaf0ff;
  --amber: #b96b00;
  --amber-soft: #fff1d5;
  --red: #c64343;
  --red-soft: #fde9e9;
  --violet: #7556c6;
  --violet-soft: #f0ebff;
  --pink: #c02c82;
  --pink-soft: #fde7f3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 12px 28px rgba(16, 24, 40, .07);
  --radius: 8px;
  --sidebar: 256px;
  --topbar: 72px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

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

.sidebar {
  height: 100vh;
  position: sticky;
  top: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: #153c31;
  color: #fff;
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: inset 0 -10px 22px rgba(20, 131, 95, .3);
}

.brand svg,
.nav-item svg,
.btn svg,
.icon-btn svg,
.card-icon svg,
.metric-icon svg,
.mini-icon svg {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.brand span,
.tenant-meta,
.eyebrow,
.muted,
.small-muted {
  color: var(--muted);
}

.brand span,
.tenant-meta,
.small-muted {
  font-size: 12px;
}

.tenant-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 11px 12px;
}

.tenant-name {
  font-size: 13px;
  font-weight: 750;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #425055;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  text-align: left;
  font-size: 13px;
}

.nav-item.active {
  color: var(--green);
  background: var(--green-soft);
  font-weight: 760;
}

.sidebar-summary {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfc;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.summary-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--subtle);
}

.dot.ok {
  background: var(--green);
}

.dot.warn {
  background: var(--amber);
}

.dot.danger {
  background: var(--red);
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: var(--topbar);
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 249, .94);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
  margin-bottom: 3px;
}

h3 {
  font-size: 14px;
  line-height: 1.3;
  margin-bottom: 5px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-pill,
.tag,
.mini-tag {
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.status-pill {
  height: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 12px;
  font-size: 12px;
  color: var(--muted);
}

.btn,
.icon-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 720;
  white-space: nowrap;
}

.btn.primary {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.btn.danger {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.btn.ghost {
  background: var(--surface);
}

.btn.soft {
  background: var(--surface-2);
}

.btn:disabled {
  color: var(--subtle);
  background: var(--surface-2);
  border-color: var(--line);
  cursor: not-allowed;
}

.icon-btn {
  width: 34px;
  padding: 0;
}

.view {
  display: none;
  padding: 22px 24px 36px;
  min-width: 0;
}

.view.active {
  display: block;
}

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

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

.grid.two {
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
}

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

.panel,
.card,
.metric,
.table-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  overflow: hidden;
}

.panel-head {
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.panel-body {
  padding: 16px;
}

.metric {
  min-height: 124px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.metric-icon,
.card-icon,
.mini-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  flex: none;
}

.metric-icon {
  background: var(--green-soft);
  color: var(--green);
}

.metric-value {
  font-size: 28px;
  font-weight: 820;
  line-height: 1;
  margin-top: 10px;
}

.metric-sub {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.metric-sub.good {
  color: var(--green);
  font-weight: 720;
}

.metric-sub.warn {
  color: var(--amber);
  font-weight: 720;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  padding: 14px;
}

.card-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.card-main {
  min-width: 0;
  flex: 1;
}

.card-main p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.card-icon.blue,
.mini-icon.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.card-icon.green,
.mini-icon.green {
  color: var(--green);
  background: var(--green-soft);
}

.card-icon.amber,
.mini-icon.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.card-icon.red,
.mini-icon.red {
  color: var(--red);
  background: var(--red-soft);
}

.card-icon.violet,
.mini-icon.violet {
  color: var(--violet);
  background: var(--violet-soft);
}

.tag,
.mini-tag {
  height: 24px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 760;
  background: var(--surface-2);
  color: var(--muted);
}

.tag.green,
.mini-tag.green {
  background: var(--green-soft);
  color: var(--green);
}

.tag.blue,
.mini-tag.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.tag.amber,
.mini-tag.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.red,
.mini-tag.red {
  background: var(--red-soft);
  color: var(--red);
}

.tag.violet,
.mini-tag.violet {
  background: var(--violet-soft);
  color: var(--violet);
}

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

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

.search {
  height: 36px;
  min-width: 260px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 12px;
  color: var(--text);
}

.segmented {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius);
}

.segmented button {
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}

.agent-grid,
.skill-grid,
.package-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.agent-card,
.skill-card,
.package-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  min-height: 184px;
  display: flex;
  flex-direction: column;
}

.agent-head,
.skill-head,
.package-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.agent-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 850;
  flex: none;
}

.agent-title,
.skill-title,
.package-title {
  min-width: 0;
  flex: 1;
}

.agent-title strong,
.skill-title strong,
.package-title strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.agent-title span,
.skill-title span,
.package-title span {
  color: var(--muted);
  font-size: 12px;
}

.agent-desc,
.skill-desc,
.package-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  min-height: 38px;
  margin: 0 0 12px;
}

.agent-meta,
.skill-meta,
.package-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
}

.table-panel {
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
  font-size: 13px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  height: 50px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #fbfcfc;
  font-size: 12px;
  font-weight: 780;
}

tr:last-child td {
  border-bottom: 0;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: #e8eeee;
  overflow: hidden;
  min-width: 120px;
}

.progress > span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--green);
}

.progress.warn > span {
  background: var(--amber);
}

.progress.danger > span {
  background: var(--red);
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 230px;
  padding: 18px 8px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.bar-item {
  flex: 1;
  min-width: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.bar {
  width: 100%;
  max-width: 34px;
  min-height: 14px;
  border-radius: 7px 7px 2px 2px;
  background: var(--blue);
}

.bar-item:nth-child(2n) .bar {
  background: var(--green);
}

.bar-item:nth-child(3n) .bar {
  background: var(--violet);
}

.bar-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.permission-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
}

.list-select {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.list-select button {
  width: 100%;
  height: 46px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
}

.list-select button:last-child {
  border-bottom: 0;
}

.list-select button.active {
  background: var(--green-soft);
  color: var(--green);
  font-weight: 760;
}

.matrix {
  display: grid;
  gap: 8px;
}

.matrix-row {
  display: grid;
  grid-template-columns: 1.1fr repeat(4, minmax(86px, .7fr));
  gap: 8px;
  align-items: center;
}

.matrix-cell {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: var(--surface);
  font-size: 12px;
}

.matrix-cell.label {
  justify-content: flex-start;
  font-size: 13px;
  font-weight: 760;
  color: var(--text);
  border-radius: var(--radius);
}

.matrix-cell.head {
  color: var(--muted);
  background: #fbfcfc;
  font-weight: 760;
}

.switch {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  display: inline-block;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
}

.switch.on {
  background: var(--green);
}

.switch.on::after {
  transform: translateX(16px);
}

.drawer,
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 30;
  background: rgba(20, 30, 35, .24);
}

.drawer.open,
.modal.open {
  display: block;
}

.drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(520px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 48px rgba(16, 24, 40, .18);
  overflow: auto;
}

.drawer-head,
.modal-head {
  min-height: 68px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-panel {
  width: min(640px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(16, 24, 40, .28);
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  overflow: hidden;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 720;
}

input,
select {
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
}

.modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.detail-list {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.detail-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.detail-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.detail-row span:first-child {
  color: var(--muted);
}

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: min(360px, calc(100vw - 32px));
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #18352b;
  color: #fff;
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(16, 24, 40, .28);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  animation: toast-in .18s ease-out;
}

.toast.warn {
  background: #835104;
}

.toast.error {
  background: #8d2f2f;
}

.toast strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.toast span {
  display: block;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255, 255, 255, .78);
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  color: var(--muted);
}

.empty-state .mini-icon {
  margin: 0 auto 12px;
}

.code-like {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 6px;
}

@media (max-width: 1180px) {
  .grid.kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .agent-grid,
  .skill-grid,
  .package-grid,
  .grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  :root {
    --sidebar: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .sidebar-summary {
    margin-top: 0;
  }

  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    padding: 14px 16px;
  }

  .top-actions {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .view {
    padding: 16px;
  }

  .grid.kpi-grid,
  .agent-grid,
  .skill-grid,
  .package-grid,
  .grid.three,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    min-width: 0;
    width: 100%;
  }

  .matrix-row {
    grid-template-columns: 1fr 1fr;
  }

  .matrix-cell.head {
    display: none;
  }
}
