:root {
  --bg: #eef4fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e3e8ef;
  --text: #1d2733;
  --muted: #6a7480;
  --blue: #2373e6;
  --blue-soft: #e8f1ff;
  --green: #16a36d;
  --green-soft: #e7f7ef;
  --amber: #d98217;
  --amber-soft: #fff4df;
  --red: #d84d4d;
  --red-soft: #fff0f0;
  --purple: #7357c4;
  --shadow: 0 8px 22px rgba(31, 45, 61, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px;
  background: #182231;
  color: #dce6f2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 4px;
  color: #8e9aaa;
  font-size: 12px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #2f6fed, #16b981);
  color: #fff;
  font-weight: 800;
}

.brand-mark.large {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  font-size: 24px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #c2cbd6;
  text-align: left;
}

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

.nav-item.active {
  background: #2f6fed;
  color: #fff;
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: inherit;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #9aa7b7;
  font-size: 12px;
}

.sidebar-foot strong {
  display: block;
  margin-top: 6px;
  color: #fff;
  overflow-wrap: anywhere;
}

.main {
  min-width: 0;
  padding: 26px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.25;
}

h2 {
  font-size: 18px;
}

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

.primary-btn,
.secondary-btn,
.ghost-btn,
.small-btn,
.icon-btn,
.text-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 16px;
}

.primary-btn {
  background: #2f6fed;
  color: #fff;
  box-shadow: 0 8px 18px rgba(47, 111, 237, 0.18);
}

.primary-btn.full {
  width: 100%;
}

.secondary-btn {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.ghost-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.small-btn {
  min-height: 32px;
  padding: 0 10px;
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--muted);
}

.icon-btn {
  width: 38px;
  padding: 0;
  background: var(--surface);
  border-color: var(--line);
}

.text-btn {
  min-height: 30px;
  padding: 0;
  background: transparent;
  color: var(--blue);
}

.notice-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 13px 16px;
  border: 1px solid #cfe6d8;
  border-radius: 8px;
  background: #f2fbf6;
  color: #24523b;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.notice-divider {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: #cfe6d8;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.summary-card,
.panel,
.content-band,
.toolbar,
.store-card,
.knowledge-card,
.agent-card,
.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-card {
  min-height: 118px;
  padding: 18px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.summary-card strong {
  display: block;
  margin-top: 12px;
  color: #111827;
  font-size: 30px;
  line-height: 1.1;
}

.summary-card small {
  color: var(--green);
}

.content-band {
  padding: 22px;
  margin-bottom: 18px;
}

.band-head p,
.toolbar p {
  margin-top: 5px;
  color: var(--muted);
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.work-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  min-height: 148px;
  padding: 16px;
  border: 1px solid #edf2f7;
  border-radius: 8px;
  background: var(--surface-soft);
}

.work-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
}

.accent-blue .work-icon {
  background: var(--blue);
}

.accent-green .work-icon {
  background: var(--green);
}

.accent-amber .work-icon {
  background: var(--amber);
}

.accent-purple .work-icon {
  background: var(--purple);
}

.work-item strong,
.work-item span {
  display: block;
}

.work-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.work-item .text-btn {
  grid-column: 2;
  justify-self: start;
  margin-top: 6px;
}

.two-column,
.settings-layout,
.security-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 20px;
}

.task-list,
.audit-list,
.rule-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.task-row,
.audit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.task-row span,
.audit-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  margin-bottom: 16px;
  padding: 18px;
}

.toolbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-input {
  width: min(360px, 42vw);
  background: var(--surface-soft);
}

.filter-select {
  width: 160px;
  background: var(--surface-soft);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 600;
}

td {
  color: var(--text);
}

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

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
}

img.avatar {
  display: block;
  object-fit: cover;
}

.stacked-cell {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.muted-line {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.member-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.text-btn.danger {
  color: var(--red);
}

.empty-text {
  margin-top: 14px;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
}

.pill.success {
  background: var(--green-soft);
  color: var(--green);
}

.pill.danger {
  background: var(--red-soft);
  color: var(--red);
}

.pill.muted {
  background: var(--surface-soft);
  color: var(--muted);
}

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

.permission-grid {
  margin-top: 16px;
}

.permission-card,
.store-card,
.knowledge-card,
.agent-card {
  padding: 18px;
}

.permission-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.permission-card h3,
.store-card h3,
.knowledge-card h3,
.agent-card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.permission-card ul,
.rule-list {
  padding-left: 18px;
  color: var(--muted);
}

.store-card {
  display: grid;
  gap: 14px;
}

.store-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.store-meta strong {
  color: var(--text);
}

.pill-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.wide-meta {
  grid-column: 1 / -1;
}

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

.knowledge-card,
.agent-card {
  display: grid;
  gap: 12px;
}

.knowledge-top,
.agent-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.toggle-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cad2dc;
}

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

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.settings-layout {
  margin-top: 18px;
}

.settings-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.danger-panel {
  border-color: #ffd8d8;
}

.security-grid {
  align-items: start;
}

.wide-panel {
  grid-column: 1 / -1;
}

.flow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.flow div {
  min-height: 38px;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--surface-soft);
  color: var(--text);
}

.flow span {
  color: var(--muted);
}

.domain-box {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

code {
  display: inline-block;
  width: fit-content;
  border-radius: 8px;
  padding: 7px 9px;
  background: #101722;
  color: #d8f5ff;
}

.audit-table {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

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

.usage-stat {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.usage-stat span,
.usage-row small,
.usage-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.usage-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
  color: var(--text);
}

.usage-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.usage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.usage-main,
.usage-metrics {
  display: grid;
  gap: 5px;
}

.usage-main span {
  color: var(--muted);
  font-size: 13px;
}

.usage-main small {
  overflow-wrap: anywhere;
}

.usage-metrics {
  justify-items: end;
  text-align: right;
}

.usage-metrics strong {
  color: var(--text);
}

.danger-text {
  color: var(--red) !important;
}

.login-mask {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 23, 34, 0.45);
  backdrop-filter: blur(6px);
}

.login-mask.hidden {
  display: none;
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
}

.login-panel h2 {
  margin-top: 16px;
  text-align: center;
  font-size: 24px;
}

.login-panel p {
  margin: 8px 0 20px;
  color: var(--muted);
  text-align: center;
}

.login-panel label {
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(18px);
  opacity: 0;
  max-width: 360px;
  border-radius: 8px;
  padding: 12px 14px;
  background: #101722;
  color: #fff;
  box-shadow: var(--shadow);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .brand div:not(.brand-mark),
  .nav-item span:last-child,
  .sidebar-foot {
    display: none;
  }

  .brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .summary-grid,
  .work-grid,
  .usage-summary,
  .permission-grid,
  .store-grid,
  .knowledge-grid,
  .agent-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .work-item {
    min-height: 132px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 20;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: 64px;
    display: block;
    padding: 7px 8px;
  }

  .brand {
    display: none;
  }

  .nav-list {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
  }

  .nav-item {
    min-height: 50px;
    display: grid;
    justify-items: center;
    gap: 2px;
    font-size: 11px;
  }

  .nav-item span:last-child {
    display: block;
  }

  .main {
    padding: 18px 14px 88px;
  }

  .topbar,
  .toolbar,
  .band-head,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .toolbar-actions,
  .search-input {
    width: 100%;
  }

  .filter-select {
    width: 100%;
  }

  .summary-grid,
  .work-grid,
  .usage-summary,
  .two-column,
  .settings-layout,
  .security-grid,
  .permission-grid,
  .store-grid,
  .knowledge-grid,
  .agent-grid {
    grid-template-columns: 1fr;
  }

  .work-item {
    grid-template-columns: 44px minmax(0, 1fr);
    min-height: auto;
  }

  .work-item .text-btn {
    grid-column: 2;
    justify-self: start;
  }

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

  .usage-metrics {
    justify-items: start;
    text-align: left;
  }
}
