:root {
  color-scheme: light;
  --page: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #17202a;
  --muted: #66717d;
  --line: #dce2e7;
  --line-strong: #c8d0d7;
  --blue: #1f67d2;
  --blue-soft: #eaf2ff;
  --green: #157a55;
  --green-soft: #e7f5ee;
  --amber: #966200;
  --amber-soft: #fff5d9;
  --red: #b93535;
  --red-soft: #ffeded;
  --shadow: 0 1px 2px rgba(25, 37, 49, .07);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 20px; letter-spacing: 0; }
body { margin: 0; min-width: 960px; overflow-x: hidden; background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.5; }
button, a, textarea, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.workbench-shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; z-index: 20; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px; background: #202a33; color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 52px; color: #fff; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.28); border-radius: 6px; background: #2f72ce; font-size: 13px; font-weight: 800; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 15px; }
.brand-copy small { color: #aeb8c0; font-size: 12px; }
.section-nav { display: grid; gap: 4px; margin-top: 28px; }
.section-nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-left: 3px solid transparent; border-radius: 4px; color: #c9d1d7; text-decoration: none; }
.section-nav a span { color: #7f8c97; font-size: 11px; }
.section-nav a:hover, .section-nav a:focus-visible, .section-nav a.active { border-left-color: #5aa0ff; background: #2b3741; color: #fff; outline: none; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 12px; border-top: 1px solid #394550; color: #aeb8c0; font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #55c790; }

.main-content { min-width: 0; max-width: 1600px; width: 100%; margin: 0 auto; padding: 18px 24px 34px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 76px; }
.eyebrow { margin: 0 0 4px; color: #5c6873; font-size: 12px; font-weight: 700; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: 26px; line-height: 1.2; }
h2 { margin: 0; font-size: 20px; line-height: 1.3; }
h3 { margin: 0; font-size: 15px; line-height: 1.35; }
.topbar-context { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions, .composer-actions, .selection-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.primary-button, .secondary-button, .icon-button, .state-lab button { min-height: 44px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; color: var(--ink); }
.primary-button { border-color: var(--blue); background: var(--blue); color: #fff; font-weight: 700; }
.secondary-button:hover:not(:disabled), .state-lab button:hover { border-color: var(--blue); color: var(--blue); }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.icon-button { width: 44px; padding: 0; font-size: 24px; line-height: 1; }
.full-button { width: 100%; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible, pre:focus-visible { outline: 3px solid rgba(31,103,210,.28); outline-offset: 2px; }

.prototype-disclosure { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; min-height: 40px; margin: 8px 0 18px; padding: 8px 12px; border: 1px solid #e7d49d; border-radius: 5px; background: #fff9e8; color: #674b09; font-size: 12px; }
.prototype-disclosure span:last-child { margin-left: auto; color: #796b45; }
.role-context-strip { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; margin: -6px 0 18px; padding: 10px 12px; border: 1px solid #cbd9ec; border-left: 4px solid var(--blue); border-radius: 5px; background: #f7faff; }
.role-context-strip > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.role-context-label { color: var(--muted); font-size: 11px; font-weight: 700; }
.role-context-strip strong { overflow-wrap: anywhere; font-size: 13px; }
.role-context-actions { display: flex; align-items: center; gap: 8px; }
.role-context-actions label { color: var(--muted); font-size: 11px; font-weight: 700; }
.role-context-actions select { min-width: 180px; min-height: 40px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; }
.business-section { scroll-margin-top: 18px; margin: 0 -24px; padding: 24px; border-top: 1px solid var(--line); background: var(--surface); }
.business-section + .business-section { margin-top: 12px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-meta { color: var(--muted); font-size: 12px; }

.intent-form { padding: 18px; border: 1px solid #cbd9ec; border-left: 4px solid var(--blue); border-radius: 5px; background: #f8fbff; box-shadow: var(--shadow); }
.intent-form > label { display: block; margin-bottom: 8px; color: #3f4b57; font-size: 12px; font-weight: 800; }
textarea { width: 100%; min-height: 96px; resize: vertical; padding: 14px 15px; border: 1px solid #aebdce; border-radius: 5px; background: #fff; color: var(--ink); font-size: 16px; line-height: 1.65; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 12px; }
.composer-footer p { margin: 0; color: var(--muted); font-size: 12px; }

.explanation-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr); gap: 14px; }
.explanation-card { min-width: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.card-heading > span { color: var(--muted); font-size: 11px; }
.safe-badge { padding: 3px 7px; border-radius: 3px; background: var(--green-soft); color: var(--green) !important; font-weight: 700; }
.boolean-expression { min-height: 116px; padding: 18px; }
.expression-placeholder { margin: 82px auto 0; max-width: 390px; color: var(--muted); text-align: center; }
.expression-group { position: relative; display: grid; gap: 8px; padding-left: 42px; }
.expression-group + .expression-group { margin-top: 8px; }
.expression-group.nested { margin-left: 28px; padding: 10px 0 10px 42px; border-left: 2px solid #d5dfeb; }
.logic-badge { position: absolute; left: 0; top: 7px; min-width: 34px; padding: 3px 5px; border-radius: 3px; background: #263746; color: #fff; text-align: center; font-size: 10px; font-weight: 800; }
.logic-badge.or { background: var(--blue); }
.logic-badge.not { background: var(--red); }
.condition-row { display: grid; grid-template-columns: 1.3fr .55fr .65fr .8fr .45fr .8fr .85fr; gap: 6px; align-items: stretch; }
.condition-cell { min-width: 0; padding: 7px 8px; border: 1px solid #dfe5ea; border-radius: 4px; background: #fff; }
.condition-cell small { display: block; margin-bottom: 2px; color: #7b8791; font-size: 10px; }
.condition-cell strong { display: block; overflow-wrap: anywhere; font-size: 12px; }
.condition-cell.pending strong { color: var(--amber); }
.expression-legend { display: grid; grid-template-columns: 1.3fr .55fr .65fr .8fr .45fr .8fr .85fr; gap: 6px; padding: 8px 16px 12px 58px; border-top: 1px solid var(--line); color: #78838d; font-size: 10px; }
.business-plan { min-height: 116px; padding: 18px; background: #f7fafc; color: var(--ink); font-size: 14px; line-height: 1.8; }
.allowlist-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.allowlist-grid div { min-height: 70px; padding: 10px 12px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); }
.allowlist-grid div:nth-child(even) { border-right: 0; }
.allowlist-grid strong, .allowlist-grid span { display: block; }
.allowlist-grid strong { font-size: 11px; }
.allowlist-grid span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.status-pill { padding: 4px 9px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.status-pill.pending { background: #eef1f3; color: #5f6972; }
.status-pill.ready { background: var(--green-soft); color: var(--green); }
.status-pill.warning { background: var(--amber-soft); color: var(--amber); }
.ambiguity-panel { margin-top: 14px; padding: 14px; border: 1px solid #e7d49d; border-radius: 5px; background: #fff9e8; }
.ambiguity-panel p { margin: 5px 0 10px; color: #715817; }
.ambiguity-options { display: flex; gap: 18px; margin-bottom: 12px; }

.results-heading { margin-bottom: 12px; }
.result-heading-meta { display: grid; justify-items: end; gap: 4px; color: var(--muted); font-size: 11px; }
.selection-toolbar { position: sticky; top: 0; z-index: 12; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 62px; margin-bottom: 10px; padding: 9px 12px; border: 1px solid #cbd9ec; border-radius: 5px; background: #f5f9fe; box-shadow: 0 2px 6px rgba(25,37,49,.08); }
#selection-summary { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
#selection-summary span { color: var(--muted); font-size: 12px; }
.table-wrap { width: 100%; overflow-x: hidden; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.business-table { width: 100%; min-width: 0; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.business-table th { position: sticky; top: 0; z-index: 3; padding: 10px 9px; border-bottom: 1px solid var(--line); background: #eef2f5; color: #4d5964; text-align: left; font-size: 11px; }
.business-table th, .business-table td { min-width: 0; width: auto; overflow-wrap: anywhere; word-break: break-word; }
.business-table .select-column { left: 0; z-index: 6; width: 64px; }
.business-table .identity-column { left: 64px; z-index: 5; width: 162px; }
.business-table td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 12px; background: #fff; }
.business-table td:first-child { position: sticky; left: 0; z-index: 2; width: 64px; background: #fff; }
.business-table td:nth-child(2) { position: sticky; left: 64px; z-index: 2; width: 162px; background: #fff; box-shadow: 5px 0 7px rgba(25,37,49,.04); }
.business-table tr:hover td { background: #f9fbfd; }
.business-table tr:hover td:first-child, .business-table tr:hover td:nth-child(2) { background: #f9fbfd; }
.checkbox-label { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.checkbox-label input, .row-select { width: 18px; height: 18px; accent-color: var(--blue); }
.customer-identity { display: grid; gap: 2px; }
.customer-identity strong { font-size: 13px; }
.customer-identity span, .customer-identity code { color: var(--muted); font-size: 10px; }
.customer-identity code { white-space: normal; word-break: break-all; }
.unknown-value { color: #7b5a13; }
.source-value { color: var(--green); }
.dynamic-value { display: inline-flex; padding: 3px 6px; border-radius: 3px; background: var(--amber-soft); color: var(--amber); }
.customer-link { color: var(--blue); font-weight: 700; white-space: nowrap; word-break: keep-all; }
.result-state { min-height: 220px; display: grid; place-items: center; border: 1px solid var(--line); border-top: 0; background: var(--surface-soft); text-align: center; }
.result-state > div { max-width: 560px; display: grid; justify-items: center; gap: 8px; padding: 26px; }
.result-state h3 { font-size: 17px; }
.result-state p { margin: 0; color: var(--muted); }
.state-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 6px; background: #e5edf7; color: var(--blue); font-weight: 800; }
.state-mark.danger { background: var(--red-soft); color: var(--red); }
.state-mark.warning { background: var(--amber-soft); color: var(--amber); }
.loading-mark { width: 32px; height: 32px; border: 3px solid #d5e1f2; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.collection-summary { display: grid; grid-template-columns: 1.3fr 1.2fr .7fr .85fr 1.4fr; border: 1px solid var(--line); border-top: 0; background: #fff; }
.collection-summary > div { min-width: 0; min-height: 72px; padding: 10px 12px; border-right: 1px solid var(--line); }
.collection-summary > div:last-child { border-right: 0; }
.collection-summary span, .collection-summary strong { display: block; }
.collection-summary span { color: var(--muted); font-size: 10px; }
.collection-summary strong { margin-top: 4px; font-size: 11px; overflow-wrap: anywhere; }

dialog { width: min(620px, calc(100vw - 80px)); max-height: calc(100vh - 80px); padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; box-shadow: 0 18px 48px rgba(24,34,44,.22); }
dialog::backdrop { background: rgba(20,30,40,.38); }
.dialog-heading { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.state-lab { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 20px; }

@media (max-width: 1500px) {
  .workbench-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .main-content { padding-inline: 18px; }
  .business-section { margin-inline: -18px; padding-inline: 18px; }
  .topbar { align-items: flex-start; }
  .explanation-grid { grid-template-columns: 1fr; }
  .condition-row, .expression-legend { grid-template-columns: 1.15fr .5fr .6fr .75fr .42fr .75fr .8fr; }
  .collection-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .collection-summary > div:nth-child(3) { border-right: 0; }
  .collection-summary > div:nth-child(n+4) { border-top: 1px solid var(--line); }
  .selection-toolbar { align-items: flex-start; }
  #selection-summary { display: grid; gap: 4px; }
  .table-wrap { overflow-x: hidden; }
  .business-table thead { display: none; }
  .business-table,
  .business-table tbody,
  .business-table tr,
  .business-table td {
    display: block;
    width: 100%;
  }
  .business-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
  }
  .business-table td {
    min-width: 0;
    padding: 0;
    border-bottom: 0;
    background: transparent !important;
    font-size: 12px;
    overflow-wrap: anywhere;
    word-break: break-word;
    position: static !important;
    left: auto !important;
    box-shadow: none !important;
  }
  .business-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
  }
  .business-table td:first-child {
    width: auto;
  }
  .business-table td:nth-child(1),
  .business-table td:nth-child(2),
  .business-table td:nth-child(6),
  .business-table td:nth-child(7),
  .business-table td:nth-child(8),
  .business-table td:nth-child(9) {
    grid-column: 1 / -1;
  }
  .business-table td:nth-child(1)::before,
  .business-table td:nth-child(2)::before {
    margin-bottom: 6px;
  }
  .business-table td:nth-child(1) input {
    margin-right: 8px;
  }
  .business-table td:nth-child(2) {
    display: grid;
    gap: 4px;
  }
  .business-table td:nth-child(10) a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
  }
  .business-table tr:hover td {
    background: transparent !important;
  }
  .result-heading-meta {
    justify-items: start;
  }
}
.settings-button {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-button svg {
  width: 19px;
  height: 19px;
}


.login-page {
  min-width: 960px;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef2f5;
}

.login-shell {
  width: min(440px, calc(100vw - 80px));
}

.login-panel {
  display: grid;
  gap: 24px;
  padding: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(25, 37, 49, .12);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand > div {
  display: grid;
}

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

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

.login-brand .brand-mark {
  color: #fff;
}

.login-form {
  display: grid;
  gap: 8px;
}

.login-form label {
  margin-top: 6px;
  color: #3f4b57;
  font-size: 12px;
  font-weight: 700;
}

.login-form input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}

.login-form .primary-button {
  margin-top: 8px;
}

.login-error {
  min-height: 21px;
  margin: 2px 0 0;
  color: var(--red);
  font-size: 12px;
}

.login-boundary {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

@media (min-width: 1181px) and (max-width: 1500px) {
  .business-table tr { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .business-table td:nth-child(6),
  .business-table td:nth-child(7),
  .business-table td:nth-child(8),
  .business-table td:nth-child(9) { grid-column: auto; }
}
