:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --border: #d9e1ed;
  --border-strong: #c6d0df;
  --text: #0f172a;
  --muted: #516179;
  --primary: #1677ff;
  --primary-soft: #eaf2ff;
  --blue: #1677ff;
  --red: #b42318;
  --green: #027a48;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.02), 0 10px 30px rgba(15, 23, 42, 0.035);
  --sider-width: 220px;
  --header-height: 64px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body.logged-out .layout {
  display: none;
}

body:not(.logged-out) .auth-screen {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.layout {
  min-height: 100vh;
  display: block;
  background: var(--bg);
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.login-shell {
  width: min(940px, 100%);
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.login-brand,
.login-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 28px;
  background: #172033;
  color: #fff;
}

.login-brand strong {
  font-size: 24px;
}

.login-brand span {
  color: #b8c2d1;
  line-height: 1.55;
}

.login-panel {
  padding: 24px;
}

.login-copy {
  margin-bottom: 18px;
}

.login-copy h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.login-copy p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 120;
  width: var(--sider-width);
  background: #ffffff;
  color: var(--text);
  padding: 0 12px 18px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  box-shadow: 10px 0 30px rgba(15, 23, 42, 0.035);
}

.brand {
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 8px 8px;
  margin-bottom: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-copy strong {
  font-size: 18px;
  line-height: 1.15;
}

.brand-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.subtle {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  padding: 0 8px 14px;
  border-bottom: 1px solid #eef2f7;
}

.section-title {
  color: #7b8aa3;
  font-size: 12px;
  margin: 22px 8px 8px;
}

.nav {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  padding-bottom: 132px;
}

.nav li {
  margin-bottom: 4px;
}

.nav-group {
  color: #7b8aa3;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 16px 8px 7px;
}

.nav button {
  width: 100%;
  min-height: 38px;
  text-align: left;
  background: transparent;
  color: #14213f;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  white-space: normal;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.nav button::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #c6d0df;
  flex: 0 0 auto;
}

.nav button:hover {
  background: #f3f7fc;
}

.nav button.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
  font-weight: 700;
}

.nav button.active::before {
  background: var(--primary);
}

.nav-details {
  border: 1px solid transparent;
  border-radius: 6px;
}

.nav-details summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #14213f;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}

.nav-details summary::-webkit-details-marker {
  display: none;
}

.nav-details summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #c6d0df;
  flex: 0 0 auto;
}

.nav-details[open] summary {
  background: #f3f7fc;
}

.nav-details > div {
  display: grid;
  gap: 4px;
  padding: 4px 0 0 14px;
}

.nav-details button {
  min-height: 34px;
  font-size: 12px;
}

.sidebar-footer {
  position: fixed;
  left: 12px;
  bottom: 14px;
  z-index: 130;
  width: calc(var(--sider-width) - 24px);
  display: grid;
  gap: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 18%);
  padding-top: 22px;
}

.quick-status-card {
  display: grid;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 11px 12px;
  box-shadow: var(--shadow);
}

.quick-status-card strong {
  font-size: 13px;
}

.quick-status-card span,
.sidebar-version {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.sidebar-version {
  padding-left: 4px;
}

.workspace {
  min-width: 0;
  margin-left: var(--sider-width);
  padding: 0;
}

.topbar {
  background: var(--panel);
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  min-height: var(--header-height);
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.03);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar-title > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

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

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #344054;
  background: transparent;
  cursor: default;
  font-size: 16px;
  line-height: 1;
}

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

h1 {
  font-size: 17px;
  margin-bottom: 0;
}

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

h3 {
  font-size: 14px;
  margin-bottom: 10px;
}

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

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

input,
select,
textarea {
  min-height: 36px;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 6px 9px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.55;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.13);
}

.btn {
  min-height: 36px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 650;
}

.btn:hover {
  filter: brightness(0.96);
}

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

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

.btn.small {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 12px;
}

.btn.full {
  width: 100%;
}

.status-dot {
  min-width: 54px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.admin-badge {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  color: #0f5ab8;
  background: var(--primary-soft);
  border: 1px solid #c9ddff;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status-dot.online {
  color: #065f46;
  background: #d1fae5;
}

.status-dot.offline {
  color: #991b1b;
  background: #fee2e2;
}

.content-grid {
  padding: 26px 28px 36px;
}

.panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  min-width: 0;
}

.project-scope-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #c9ddff;
  border-radius: 8px;
  background: linear-gradient(135deg, #f7fbff 0%, #ffffff 100%);
}

.scope-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.scope-copy span,
.scope-copy small {
  color: var(--muted);
  font-size: 12px;
}

.scope-copy strong {
  color: var(--text);
  font-size: 18px;
  overflow-wrap: anywhere;
}

.scope-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.scope-actions label {
  display: grid;
  gap: 5px;
  min-width: 280px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.scope-actions select {
  min-height: 36px;
}

.context-note {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.55;
}

.context-current {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.context-current div {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  min-width: 0;
}

.context-current span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.context-current strong {
  display: block;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.context-help {
  margin-top: 12px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.context-help ul {
  margin: 7px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.page-heading-main {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.page-heading-main h2 {
  font-size: 26px;
  line-height: 1.18;
  margin: 0;
}

.page-description {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  max-width: 860px;
}

.page-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 220px;
}

.management-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.management-main-card,
.guide-panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.management-main-card {
  padding: 18px;
}

.guide-panel {
  position: sticky;
  top: calc(var(--header-height) + 18px);
  padding: 18px 18px 16px;
}

.guide-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.guide-panel ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.guide-context {
  display: grid;
  gap: 4px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

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

.guide-context strong {
  margin-bottom: 7px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.section-head h2 {
  font-size: 24px;
  line-height: 1.25;
  margin: 0;
}

.page-intro {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.page-intro strong {
  font-size: 14px;
}

.page-intro span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.home-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: linear-gradient(135deg, #ffffff 0%, #f4f8ff 100%);
}

.home-hero h2 {
  margin-bottom: 5px;
  font-size: 20px;
}

.home-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.hero-actions,
.quick-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.home-metrics {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.status-line {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

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

.status-line strong {
  font-size: 18px;
  justify-self: end;
}

.status-line small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.quick-link {
  display: grid;
  gap: 3px;
  min-width: 170px;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 11px;
  text-align: left;
  cursor: pointer;
}

.quick-link:hover {
  border-color: var(--primary);
}

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

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

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

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.inline-field select {
  min-height: 36px;
  padding: 4px 8px;
}

.page-note {
  color: var(--muted);
  font-size: 13px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  min-height: 96px;
  min-width: 0;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  display: grid;
  align-content: space-between;
}

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

.metric strong {
  font-size: 26px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.summary-strip.compact {
  grid-template-columns: repeat(4, minmax(90px, 1fr));
}

.memory-context-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.memory-browser {
  display: grid;
  grid-template-columns: minmax(520px, 1.1fr) minmax(420px, 0.9fr);
  gap: 12px;
  align-items: start;
}

.business-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  gap: 14px;
  align-items: start;
}

.business-detail-panel {
  min-height: 520px;
}

.memory-browser > div {
  min-width: 0;
}

.memory-selection-stack,
.memory-detail-stack {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.memory-project-chooser {
  margin-bottom: 12px;
}

.memory-project-switcher {
  display: grid;
  gap: 12px;
}

.memory-project-switcher summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.memory-project-switcher summary::-webkit-details-marker {
  display: none;
}

.memory-project-switcher summary span:first-child {
  display: grid;
  gap: 4px;
}

.memory-project-switcher summary strong {
  font-size: 14px;
}

.memory-project-switcher summary small {
  color: var(--muted);
  font-size: 12px;
}

.surface-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.surface-head h3 {
  margin: 0 0 4px;
}

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

.count-pill {
  min-width: 30px;
  min-height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid #c9ddff;
  background: #f2f7ff;
  color: #0f5ab8;
  font-size: 12px;
  font-weight: 800;
}

.search-field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-field input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
}

.search-field input:focus {
  outline: 2px solid rgba(24, 119, 242, 0.18);
  border-color: #8ab8ff;
}

.memory-workbench-help,
.memory-detail-empty {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.memory-workbench-help h3,
.memory-detail-empty h3 {
  margin: 0 0 5px;
}

.memory-workbench-help p,
.memory-detail-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.memory-browser .summary-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.memory-browser .two-col,
.memory-browser .three-col,
.memory-browser .profile-grid {
  grid-template-columns: 1fr;
}

.surface {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.business-user-table {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.business-user-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(180px, 1.45fr) minmax(54px, 0.42fr) minmax(64px, 0.45fr) minmax(58px, 0.42fr) minmax(130px, 1fr) minmax(126px, 0.9fr) minmax(84px, 0.55fr);
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
  text-align: left;
}

.business-user-row:last-child {
  border-bottom: 0;
}

.business-user-row:not(.table-head) {
  cursor: pointer;
}

.business-user-row:not(.table-head):hover {
  background: #f7fbff;
}

.business-user-row.selected {
  background: #eef6ff;
  box-shadow: inset 3px 0 0 var(--primary);
}

.business-user-row.table-head {
  min-height: 42px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: default;
}

.business-user-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.business-user-row strong,
.business-user-row small {
  display: block;
}

.business-user-row strong {
  font-size: 13px;
  line-height: 1.35;
}

.business-user-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.business-user-row code {
  font-size: 11px;
  white-space: normal;
}

.business-user-row em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid #c9ddff;
  border-radius: 6px;
  background: #f2f7ff;
  color: #0f5ab8;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.user-empty-state {
  display: grid;
  gap: 6px;
  min-height: 150px;
  align-content: center;
  border: 1px dashed #cbd8ea;
  border-radius: 6px;
  background: #f8fbff;
  padding: 18px;
}

.user-empty-state strong {
  color: var(--text);
  font-size: 15px;
}

.mini-form {
  display: grid;
  gap: 10px;
}

.mini-form.horizontal {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.inline-grant-form {
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: end;
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
}

.mini-form.compact-form {
  grid-template-columns: minmax(120px, 160px) minmax(150px, 1fr) minmax(180px, 1.4fr) minmax(90px, 120px) auto;
  align-items: end;
}

.divider {
  margin: 14px 0;
  border-top: 1px solid var(--border);
}

.compact-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 13px;
}

.table {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 13px;
}

.table div {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: #fff;
}

.table div:nth-child(-n + 3) {
  background: #f3f6fb;
  color: #344054;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.project-table {
  display: grid;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.project-table-head,
.project-table-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(150px, 0.9fr) minmax(92px, 0.6fr) minmax(128px, 0.7fr) minmax(150px, 0.8fr) minmax(250px, 1fr);
  align-items: center;
}

.project-table-head {
  min-height: 42px;
  background: #f3f6fb;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.project-table-row {
  min-height: 64px;
  border-top: 1px solid var(--border);
}

.project-table-head > div,
.project-table-row > div {
  min-width: 0;
  padding: 10px;
}

.project-table-row strong,
.project-table-row span,
.project-table-row code,
.project-table-row small {
  display: block;
  overflow-wrap: anywhere;
}

.project-table-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.project-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.project-empty-state {
  display: grid;
  gap: 6px;
  text-align: left;
}

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

.project-chooser {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 11px;
  text-align: left;
  cursor: pointer;
}

.project-chooser:hover {
  border-color: #8ab8ff;
  background: #f7fbff;
}

.project-chooser.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}

.project-chooser span {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.project-chooser span:first-child {
  display: grid;
  gap: 3px;
}

.project-chooser strong,
.project-chooser small {
  overflow-wrap: anywhere;
}

.project-chooser small {
  color: var(--muted);
  font-size: 12px;
}

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

.checkbox-line {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.checkbox-line input {
  width: 16px;
  height: 16px;
}

.feature-table {
  display: grid;
  grid-template-columns: 1fr 1fr 80px 96px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 12px;
}

.feature-table div {
  min-width: 0;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: #fff;
  overflow-wrap: anywhere;
}

.feature-table div:nth-child(-n + 4) {
  background: #f3f6fb;
  color: #344054;
  font-weight: 700;
}

.output {
  margin-top: 12px;
}

.json {
  max-height: 540px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f172a;
  color: #dbeafe;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.notice {
  border: 1px solid #c9ddff;
  background: var(--primary-soft);
  color: #0f5ab8;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.notice.error {
  color: #8a1f14;
  background: #fff1f0;
  border-color: #f4b8b4;
}

.notice.strong p {
  margin: 6px 0 8px;
  color: #0f5ab8;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 3px 8px;
  margin-right: 8px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
}

.status-badge.pass {
  color: #065f46;
  border-color: #a7dfc3;
  background: #dff7ef;
}

.status-badge.warn {
  color: #92400e;
  border-color: #f6d08f;
  background: #fff7e6;
}

.status-badge.fail {
  color: #991b1b;
  border-color: #f0aaa5;
  background: #fff1f0;
}

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

.check-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.check-item > div {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  min-width: 0;
}

.check-item strong {
  overflow-wrap: anywhere;
}

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

.action-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.75;
}

.command-block {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f172a;
  color: #dbeafe;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.env-template-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
  margin: 10px 0 12px;
}

.env-template-card h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text);
}

.env-template-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.raw-details {
  margin-top: 12px;
}

.raw-details summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

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

.project-detail-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 12px;
  align-items: start;
}

.project-detail-stack {
  display: grid;
  gap: 12px;
}

.project-detail-stack .summary-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.project-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.core-workbench-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(280px, 0.85fr);
  gap: 12px;
  align-items: start;
}

.project-detail-grid > .core-workbench-grid {
  grid-column: 1 / -1;
}

.core-workbench-grid > * {
  min-width: 0;
}

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

.span-2 {
  grid-column: 1 / -1;
}

.source-insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.source-insight-grid .metric {
  min-height: 78px;
  padding: 12px;
}

.source-insight-grid .metric strong {
  font-size: 22px;
}

.analysis-block {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
}

.analysis-block strong {
  font-size: 13px;
}

.test-result-card {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #c9ddff;
  border-radius: 8px;
  background: #f7fbff;
}

.project-card {
  display: grid;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  padding: 12px;
}

.project-card-head,
.project-card-actions,
.key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.project-card-head h3 {
  margin-bottom: 4px;
}

.project-card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.project-card-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.key-list {
  display: grid;
  gap: 7px;
}

.key-row {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
  padding: 8px;
}

.key-row span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.key-row span:first-child {
  display: grid;
  gap: 2px;
}

.key-row small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

.audit-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) auto minmax(160px, 1fr) minmax(80px, 0.5fr) minmax(180px, 1.2fr);
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  padding: 9px;
  font-size: 12px;
}

.audit-time,
.audit-row span,
.audit-row small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.audit-row strong {
  overflow-wrap: anywhere;
}

.muted,
.empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid #c9ddff;
  border-radius: 6px;
  background: #f2f7ff;
  color: #0f5ab8;
  font-size: 12px;
}

.tag.negative {
  color: #912018;
  border-color: #f3a9a1;
  background: #fff4f2;
}

.version {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

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

.list-row {
  min-height: 48px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  padding: 9px 10px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.list-row:hover {
  border-color: #8ab8ff;
  background: #f7fbff;
}

.list-row.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}

.list-row.passive {
  cursor: default;
}

.list-row span {
  display: grid;
  gap: 3px;
}

.list-row small {
  color: var(--muted);
}

.list-row em {
  color: var(--blue);
  font-style: normal;
  font-size: 12px;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(90px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.pipeline div {
  min-height: 70px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
  font-weight: 700;
  font-size: 13px;
}

.rank-list {
  display: grid;
  gap: 9px;
}

.rank-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 70px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
  padding: 10px;
}

.rank-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.rank-item p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 12px;
}

.rank-item small {
  color: #475467;
}

.rank-item > span {
  justify-self: end;
  font-weight: 800;
  color: var(--green);
}

@media (max-width: 1180px) {
  .management-grid {
    grid-template-columns: 1fr;
  }

  .guide-panel {
    position: static;
  }

  .metrics,
  .home-metrics,
  .summary-strip,
  .memory-context-strip,
  .profile-grid,
  .core-workbench-grid,
  .memory-browser,
  .business-workspace,
  .project-detail-layout,
  .project-detail-grid,
  .three-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .project-table-head,
  .project-table-row {
    grid-template-columns: minmax(180px, 1fr) minmax(140px, 0.8fr) minmax(120px, 0.7fr) minmax(220px, 1fr);
  }

  .project-table-head > div:nth-child(3),
  .project-table-row > div:nth-child(3),
  .project-table-head > div:nth-child(4),
  .project-table-row > div:nth-child(4) {
    display: none;
  }

  .business-user-row {
    grid-template-columns: minmax(180px, 1.5fr) repeat(3, minmax(52px, 0.45fr)) minmax(130px, 1fr) minmax(84px, 0.55fr);
  }

  .business-user-row > span:nth-child(6) {
    display: none;
  }
}

@media (max-width: 780px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-brand,
  .login-panel {
    padding: 18px;
  }

  .layout {
    display: block;
  }

  .sidebar {
    position: static;
    width: auto;
    max-height: 44vh;
  }

  .nav {
    padding-bottom: 0;
  }

  .business-user-row,
  .business-user-row.table-head {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .business-user-row.table-head {
    display: none;
  }

  .business-user-row span {
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }

  .business-user-row span::before {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
  }

  .business-user-row span:nth-child(1)::before {
    content: "用户";
  }

  .business-user-row span:nth-child(2)::before {
    content: "事件";
  }

  .business-user-row span:nth-child(3)::before {
    content: "Recall";
  }

  .business-user-row span:nth-child(4)::before {
    content: "画像";
  }

  .business-user-row span:nth-child(5)::before {
    content: "最近上下文";
  }

  .business-user-row span:nth-child(6)::before {
    content: "最近时间";
  }

  .business-user-row span:nth-child(7)::before {
    content: "操作";
  }

  .sidebar-footer {
    position: static;
    width: auto;
    padding-top: 8px;
  }

  .workspace {
    margin-left: 0;
    padding: 0;
  }

  .topbar {
    position: static;
    padding: 12px;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .content-grid {
    padding: 12px;
  }

  .home-hero,
  .section-head,
  .page-title-row,
  .project-scope-bar,
  .top-actions,
  .memory-workbench-help,
  .project-card-head,
  .key-row {
    align-items: stretch;
    flex-direction: column;
  }

  .btn,
  .top-actions label,
  .page-actions,
  .page-actions .btn {
    width: 100%;
  }

  .top-actions {
    flex-direction: row;
  }

  .scope-actions,
  .scope-actions label {
    width: 100%;
    min-width: 0;
  }

  .top-actions .btn,
  .top-actions .admin-badge,
  .top-actions .status-dot {
    width: auto;
  }

  .page-actions {
    min-width: 0;
  }

  .management-main-card,
  .guide-panel {
    padding: 14px;
  }

  .metrics,
  .home-metrics,
  .summary-strip,
  .two-col,
  .three-col,
  .core-workbench-grid,
  .project-test-form,
  .source-insight-grid,
  .home-grid,
  .audit-row,
  .profile-grid,
  .memory-browser,
  .business-workspace,
  .project-detail-layout,
  .project-detail-grid,
  .pipeline,
  .mini-form.compact-form,
  .project-create-form {
    grid-template-columns: 1fr;
  }

  .project-table {
    border: 0;
    background: transparent;
    gap: 10px;
  }

  .project-table-head {
    display: none;
  }

  .project-table-row {
    grid-template-columns: 1fr;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
  }

  .project-table-row > div {
    padding: 8px 10px;
  }

  .project-table-row > div:nth-child(3),
  .project-table-row > div:nth-child(4) {
    display: block;
  }
}
