:root {
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-soft: #f9fbfd;
  --text: #17212b;
  --muted: #65758b;
  --border: #dbe5ef;
  --blue: #2481cc;
  --blue-dark: #1769aa;
  --green: #138a5e;
  --orange: #b76812;
  --red: #c63d3d;
  --shadow: 0 12px 32px rgba(23, 33, 43, 0.08);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: #ffffff;
  border-right: 1px solid var(--border);
  padding: 18px 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 8px 18px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav button {
  border: 0;
  background: transparent;
  color: #344256;
  text-align: left;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.nav button.active,
.nav button:hover {
  color: var(--blue-dark);
  background: #eaf4ff;
}

.workspace {
  padding: 24px;
  display: grid;
  gap: 18px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

select,
.health-badge {
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0 12px;
  color: #344256;
}

.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(120px, 1fr));
  gap: 12px;
}

.metric-card,
.panel,
.module-card,
.material-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 14px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.dashboard-grid,
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(360px, 1fr);
  gap: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.primary-btn,
.ghost-btn {
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.primary-btn {
  color: #fff;
  background: var(--blue);
}

.primary-btn:hover {
  background: var(--blue-dark);
}

.ghost-btn {
  color: var(--blue-dark);
  background: #eaf4ff;
}

.chart {
  height: 260px;
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 18px 8px 4px;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
  border: 1px solid #d8e9fb;
}

.bar {
  flex: 1;
  min-width: 20px;
  display: grid;
  align-items: end;
  gap: 8px;
  height: 100%;
}

.bar-fill {
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #4ba3e3 0%, var(--blue) 100%);
}

.bar span {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.health-list,
.module-grid,
.ops-grid {
  display: grid;
  gap: 10px;
}

.health-item,
.conversation-item,
.log-item,
.ops-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.health-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.module-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.module-card {
  padding: 14px;
}

.module-card strong {
  display: block;
  margin-bottom: 8px;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: #edf2f7;
  color: #3d4b5f;
}

.status.online,
.status.implemented,
.status.completed,
.status.success,
.status.enabled,
.status.healthy,
.status.running,
.status.connected {
  background: #e5f6ee;
  color: var(--green);
}

.status.warning,
.status.interface,
.status.scheduled,
.status.pending {
  background: #fff3df;
  color: var(--orange);
}

.status.failed,
.status.error,
.status.planned {
  background: #ffe8e8;
  color: var(--red);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #f9fbfd;
}

.bot-name,
.task-name {
  font-weight: 700;
}

.subtext {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.material-rail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-height: 412px;
  overflow: auto;
}

.material-card {
  padding: 12px;
  box-shadow: none;
}

.thumb {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #eaf4ff;
  color: var(--blue-dark);
  font-weight: 800;
  margin-bottom: 10px;
}

.conversation-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.conversation-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.log-list {
  display: grid;
  gap: 8px;
  max-height: 222px;
  overflow: auto;
}

.log-item {
  font-size: 13px;
}

.ops-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ops-item strong {
  display: block;
  margin-bottom: 5px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #17212b;
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1200px) {
  .metric-grid,
  .module-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dashboard-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .top-actions,
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .metric-grid,
  .module-grid,
  .ops-grid,
  .material-rail {
    grid-template-columns: 1fr;
  }
}
