:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d8dde6;
  --text: #172033;
  --muted: #657085;
  --soft: #f8fafc;
  --accent: #0d766f;
  --accent-dark: #0a5d58;
  --accent-soft: #e8f4f2;
  --warn: #9a3412;
  --shadow: 0 18px 45px rgba(25, 31, 45, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login-panel {
  width: min(440px, calc(100vw - 32px));
  margin: 12vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  font-size: 28px;
  line-height: 1.2;
  margin-bottom: 8px;
}

h2 {
  font-size: 18px;
  margin-bottom: 0;
}

.subtle {
  color: var(--muted);
}

.page-summary {
  max-width: 720px;
  margin-bottom: 0;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--warn);
  font-size: 13px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 24px;
}

.sidebar nav {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.sidebar button {
  display: grid;
  gap: 2px;
  justify-content: flex-start;
  width: 100%;
  background: transparent;
  color: var(--text);
  line-height: 1.35;
  min-height: 54px;
  text-align: left;
  white-space: normal;
}

.sidebar button#dashboardNav,
.sidebar button.ghost {
  display: block;
}

.nav-cn,
.nav-en {
  display: block;
  overflow-wrap: anywhere;
}

.nav-cn {
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.nav-en {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar button.active,
.sidebar button:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.sidebar button.active .nav-cn,
.sidebar button:hover .nav-cn,
.sidebar button.active .nav-en,
.sidebar button:hover .nav-en {
  color: var(--accent-dark);
}

.sidebar button.ghost {
  border: 1px solid var(--line);
  color: var(--muted);
}

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

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

.user-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.board-annotation {
  margin-bottom: 18px;
  border: 1px solid #bfd8d5;
  border-radius: 8px;
  background: #f4fbfa;
  box-shadow: var(--shadow);
  padding: 18px;
}

.board-annotation h2 {
  margin-bottom: 8px;
  font-size: 17px;
}

.board-annotation p {
  margin: 0;
  color: #3f5963;
  line-height: 1.75;
}

.board-feedback {
  margin-bottom: 18px;
  border: 1px solid #d8dde6;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
}

.board-feedback.loading {
  border-color: #bfd8d5;
  background: #f4fbfa;
  color: #3f5963;
}

.board-feedback.error {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

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

.quick-grid button {
  min-height: 52px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.quick-grid button:hover {
  border-color: #9bc6c1;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

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

.metric {
  min-height: 104px;
  padding: 18px;
}

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

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.module-table {
  overflow: hidden;
}

.table-header,
.module-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
}

.table-header {
  border-bottom: 1px solid var(--line);
}

.table-header button {
  justify-self: end;
  min-height: 34px;
}

.table-header span,
.module-row span {
  color: var(--muted);
  font-size: 13px;
}

.module-row > div {
  display: grid;
  gap: 4px;
}

.module-row {
  cursor: pointer;
}

.module-row:hover {
  background: var(--soft);
}

.module-row + .module-row {
  border-top: 1px solid var(--line);
}

.pill {
  justify-self: start;
  border-radius: 999px;
  background: #eef1f5;
  padding: 5px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pill.ready {
  background: #dcfce7;
  color: #166534;
}

.pill.progress {
  background: #fef3c7;
  color: #92400e;
}

.pill.quiet {
  background: #eef1f5;
  color: #64748b;
}

.os-panel {
  display: grid;
  gap: 18px;
}

.os-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
}

.os-detail section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.os-detail h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.os-detail ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.os-detail p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.brain-panel {
  display: grid;
  gap: 18px;
}

.provider-panel {
  display: grid;
  gap: 18px;
}

.permission-panel {
  display: grid;
  gap: 18px;
}

.knowledge-panel {
  display: grid;
  gap: 18px;
}

.workflow-panel {
  display: grid;
  gap: 18px;
}

.intent-panel {
  display: grid;
  gap: 18px;
}

.feishu-panel {
  display: grid;
  gap: 18px;
}

.agent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
}

.agent-row + .agent-row {
  border-top: 1px solid var(--line);
}

.agent-row p {
  margin: 6px 0;
  color: var(--muted);
}

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

.brain-workbench {
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.brain-session-bar,
.brain-form {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 140px;
  align-items: end;
  gap: 12px;
}

.brain-session-bar {
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
}

#sessionBadge {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
}

.message-form {
  grid-template-columns: minmax(0, 1fr) 120px;
}

.brain-result {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
}

.brain-result:empty {
  display: none;
}

.brain-result span,
.history-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.brain-result strong,
.brain-result p,
.history-row p {
  margin: 4px 0 0;
}

.brain-result pre {
  max-height: 260px;
  overflow: auto;
  margin: 6px 0 0;
  border-radius: 6px;
  background: #111827;
  color: #e5e7eb;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.provider-summary {
  display: grid;
}

.observability-summary {
  display: grid;
}

.provider-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 18px;
}

.provider-row + .provider-row {
  border-top: 1px solid var(--line);
}

.provider-row span,
#providerStatus {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.operational-alert-list {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.operational-alert {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.operational-alert.warning {
  border-left-color: #d97706;
}

.operational-alert.critical {
  border-left-color: #b91c1c;
}

.operational-alert-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.operational-alert-heading p,
.operational-alert-context {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.operational-alert button {
  justify-self: start;
  min-height: 34px;
}

.pill.alert-critical {
  background: #fee2e2;
  color: #991b1b;
}

.permission-grid,
.knowledge-grid,
.workflow-grid,
.intent-grid,
.feishu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
}

.permission-grid section,
.knowledge-grid section,
.workflow-grid section,
.intent-grid section,
.feishu-grid section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.permission-grid h3,
.knowledge-grid h3,
.workflow-grid h3,
.intent-grid h3,
.feishu-grid h3 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  padding: 10px 12px;
  font-size: 14px;
}

.permission-row {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.permission-row > div:first-child {
  color: var(--text);
  font-weight: 700;
}

.permission-row + .permission-row {
  border-top: 1px solid var(--line);
}

.empty-row {
  padding: 16px 12px;
  color: var(--muted);
  font-size: 13px;
}

.employee-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.employee-actions select,
.employee-actions button {
  min-height: 34px;
}

.employee-actions button {
  padding: 0 10px;
}

.employee-actions button.danger {
  background: var(--warn);
}

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

.history-list {
  display: grid;
  gap: 10px;
}

.history-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.history-row.user {
  background: #fff;
}

.history-row.assistant {
  background: #f0fdfa;
}

@media (max-width: 820px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

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

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

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

  .brain-session-bar,
  .brain-form,
  .message-form,
  .agent-row,
  .provider-row,
  .operational-alert-heading,
  .employee-actions {
    grid-template-columns: 1fr;
  }

  .table-header button {
    justify-self: start;
  }

  .permission-grid,
  .knowledge-grid,
  .workflow-grid,
  .intent-grid,
  .feishu-grid,
  .os-detail {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .content {
    padding: 18px;
  }

  .topbar,
  .table-header,
  .module-row {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .quick-grid {
    grid-template-columns: 1fr;
  }
}
