:root {
  --bg: #f6f7f5;
  --panel: #ffffff;
  --panel-strong: #f0f3ef;
  --ink: #1f2522;
  --muted: #66736c;
  --line: #d9dfd8;
  --green: #111216;
  --green-soft: #eceef3;
  --amber: #8a5b16;
  --amber-soft: #fff2cf;
  --red: #a63d40;
  --red-soft: #f8e3e1;
  --blue: #2867b2;
  --blue-soft: #e6f0ff;
  --teal: #167085;
  --teal-soft: #e2f3f7;
  --violet: #7a4ea3;
  --shadow: 0 16px 50px rgba(31, 37, 34, 0.12);
  --sidebar-width: 300px;
  --context-width: 420px;
  --ui-font-size: 13px;
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-size: var(--ui-font-size);
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0;
}

body.theme-dark {
  --bg: #080808;
  --panel: #111111;
  --panel-strong: #0d0d0d;
  --ink: #f4f4f5;
  --muted: #a1a1aa;
  --line: #2a2a2a;
  --green: #f4f4f5;
  --green-soft: #202020;
  --amber: #d6a85f;
  --amber-soft: #251d10;
  --red: #f08a8a;
  --red-soft: #2a1616;
  --blue: #a7b6c8;
  --blue-soft: #1a2027;
  --teal: #d4d4d8;
  --teal-soft: #1d1d1d;
  --violet: #a3a3a3;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
}

body.font-small {
  --ui-font-size: 12px;
}

body.font-medium {
  --ui-font-size: 13px;
}

body.font-large {
  --ui-font-size: 15px;
}

body.theme-dark .primary-button,
body.theme-dark .send-button,
body.theme-dark .flow-node.strong,
body.theme-dark .brand-mark {
  color: #08090a;
}

* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted), transparent 52%) transparent;
}

*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  min-height: 34px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted), transparent 48%);
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted), transparent 28%);
  background-clip: content-box;
}

button,
input,
select {
  font: inherit;
}

.local-icon {
  display: inline-grid;
  width: 1em;
  height: 1em;
  place-items: center;
  flex: 0 0 auto;
  color: currentColor;
  font-size: 0.9em;
  font-weight: 760;
  line-height: 1;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(360px, 1fr) var(--context-width);
  height: 100vh;
  overflow: hidden;
}

.app-shell.auth-locked {
  display: none;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  overflow: auto;
  padding: 24px;
  background: var(--bg);
}

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

.hidden {
  display: none !important;
}

.login-panel {
  display: grid;
  width: min(500px, 100%);
  gap: 16px;
  margin: auto 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.login-brand h1 {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 650;
  line-height: 1.2;
}

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

.login-status,
.login-qr-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-strong);
}

.login-status.error {
  color: var(--red);
  background: var(--red-soft);
}

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

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

.account-auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.account-auth-form input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--panel-strong);
  outline: none;
}

.account-auth-form input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.login-button {
  width: 100%;
}

.login-qr-card.hidden {
  display: none;
}

.login-qr-card strong {
  color: var(--ink);
  font-weight: 620;
}

.login-qr-card a {
  color: var(--blue);
  overflow-wrap: anywhere;
}

.setup-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.setup-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setup-card-head div {
  display: grid;
  gap: 3px;
}

.setup-card-head span,
.setup-row small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.setup-callback-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.setup-callback-field input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--panel);
  outline: none;
}

.setup-callback-field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.copy-field {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
  align-items: center;
}

.copy-field .icon-button {
  width: 42px;
  min-width: 42px;
  height: 38px;
  padding: 0;
}

.setup-progress {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.setup-progress div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 180ms ease;
}

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

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

.setup-actions .secondary-button {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}

.setup-actions .secondary-button span,
.setup-credential-form .secondary-button span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.setup-command-box {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.setup-command-box code {
  display: block;
  max-height: 84px;
  overflow: auto;
  padding: 8px;
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.setup-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
}

.setup-row > span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.setup-row.ok > span {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 48%, var(--line));
}

.setup-row.failed > span {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 48%, var(--line));
}

.setup-row.manual > span {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 48%, var(--line));
}

.setup-guide {
  display: grid;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.setup-credential-form {
  display: grid;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.setup-credential-head {
  display: grid;
  gap: 4px;
}

.setup-credential-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.setup-credential-form input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--panel);
  outline: none;
}

.setup-credential-form input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.setup-credential-form .secondary-button {
  width: 100%;
  min-height: 42px;
  white-space: normal;
}

.setup-advanced {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.setup-advanced summary {
  cursor: pointer;
  color: var(--ink);
}

.setup-advanced[open] {
  gap: 10px;
}

.setup-guide span,
.setup-credential-head span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.sidebar,
.workspace-main,
.context-panel {
  min-width: 0;
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  position: relative;
  border-right: 1px solid var(--line);
  background: var(--panel-strong);
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 3;
}

.sidebar-resize-handle::after {
  content: "";
  position: absolute;
  top: 46%;
  right: 3px;
  width: 2px;
  height: 56px;
  border-radius: 999px;
  background: transparent;
  transition: background 120ms ease;
}

.sidebar-resize-handle:hover::after,
body.resizing-sidebar .sidebar-resize-handle::after {
  background: var(--teal);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 12px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  font-weight: 720;
}

.brand-title {
  font-weight: 650;
}

.left-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--line);
}

.permission-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 30px;
  height: 30px;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--teal);
  background: transparent;
  font-weight: 650;
  white-space: nowrap;
}

.permission-pill i,
.permission-pill .local-icon {
  width: 14px;
  height: 14px;
}

.segmented-control {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.segmented-control.compact {
  width: auto;
}

.segmented-control button {
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 600;
  white-space: nowrap;
}

.segmented-control button.active {
  color: var(--green);
  background: var(--green-soft);
}

.icon-switch {
  display: inline-flex;
  grid-auto-flow: unset;
  grid-auto-columns: unset;
  width: max-content;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
}

.icon-switch button {
  display: grid;
  width: 28px;
  height: 28px;
  min-height: 0;
  place-items: center;
  padding: 0;
  border-radius: 7px;
}

.icon-switch button.active {
  background: var(--green-soft);
}

.icon-switch i,
.icon-switch .local-icon {
  width: 14px;
  height: 14px;
}

.control-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.font-scale-switch {
  gap: 3px;
}

.font-mark {
  color: currentColor;
  font-weight: 650;
  line-height: 1;
}

.font-mark-small {
  font-size: 10px;
}

.font-mark-medium {
  font-size: 12px;
}

.font-mark-large {
  font-size: 14px;
}

.brand-subtitle,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 8px 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.sidebar-search {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 12px;
  padding: 0 10px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.sidebar-search i,
.sidebar-search .local-icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.sidebar-search input {
  min-width: 0;
  border: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
}

.global-nav {
  display: grid;
  gap: 3px;
  padding: 0 10px 8px;
}

.global-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.global-nav-item.active {
  color: var(--green);
  background: var(--green-soft);
  font-weight: 650;
}

.global-nav-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.department-list {
  flex: 1;
  overflow: auto;
  padding: 0 10px 12px;
}

.sidebar-subhead {
  margin: 12px 4px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.business-tree {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.business-tree-head {
  display: grid;
  gap: 3px;
  margin: 2px 2px 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.business-tree-head strong {
  font-weight: 650;
}

.business-tree-head span {
  color: var(--muted);
  font-size: 11px;
}

.business-node-list,
.business-node-children {
  display: grid;
  gap: 2px;
}

.business-node-row {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.business-node-row.level-1 {
  padding-left: 18px;
}

.business-node-row.level-2 {
  padding-left: 28px;
}

.business-node-row.level-3 {
  padding-left: 38px;
}

.business-node-row.level-4,
.business-node-row.level-5 {
  padding-left: 48px;
}

.business-node-row.active {
  color: var(--green);
  background: var(--green-soft);
  font-weight: 620;
}

.business-node-row i,
.business-node-row .local-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.business-node-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.business-node-title,
.business-node-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.business-node-title {
  font-size: 12px;
}

.business-node-meta {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
}

.department {
  margin-bottom: 10px;
}

.department-head {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  min-height: 40px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.department-head.active {
  background: var(--green-soft);
}

.department-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: transform 160ms ease;
}

.department.collapsed .department-toggle {
  transform: rotate(-90deg);
}

.department-head i,
.department-head .local-icon,
.doc-row i,
.doc-row .local-icon,
.global-nav-item i,
.global-nav-item .local-icon,
.settings-button i,
.settings-button .local-icon,
.secondary-button i,
.secondary-button .local-icon,
.primary-button i,
.primary-button .local-icon,
.quick-actions i,
.quick-actions .local-icon,
.status-pill i,
.status-pill .local-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.department-toggle i,
.department-toggle .local-icon {
  width: 15px;
  height: 15px;
}

.department-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.department-copy {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 2px;
}

.department-summary {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-empty {
  display: grid;
  gap: 6px;
  margin: 4px 2px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
}

.sidebar-empty strong {
  color: var(--ink);
}

.doc-list {
  display: grid;
  gap: 2px;
  padding-left: 18px;
}

.doc-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.doc-row.active {
  color: var(--green);
  background: var(--green-soft);
  font-weight: 600;
}

.doc-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  display: flex;
  justify-content: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.settings-button,
.secondary-button,
.primary-button,
.quick-actions button,
.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  font-weight: 560;
  white-space: nowrap;
}

.settings-button {
  width: 34px;
  height: 34px;
  min-height: 0;
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  padding: 0;
}

.workspace-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--bg);
}

.workspace-main > * {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.active-context {
  min-width: 0;
}

.active-context .eyebrow,
.thread-meta {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-context h1,
.context-header h2,
.modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 620;
  line-height: 1.25;
}

.thread-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-settings-button {
  display: none;
}

.recovery-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  justify-content: center;
  gap: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.pending {
  position: relative;
  width: 34px;
  color: var(--amber);
  background: var(--amber-soft);
}

.status-count {
  position: absolute;
  right: -3px;
  top: -4px;
  display: grid;
  min-width: 15px;
  height: 15px;
  place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  color: var(--bg);
  background: var(--amber);
  font-size: 10px;
  font-weight: 650;
  line-height: 1;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
  padding: 0 12px;
}

.secondary-button.danger {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red), var(--line) 55%);
}

.primary-button {
  border: 0;
  color: #fff;
  background: var(--green);
  padding: 0 14px;
  font-weight: 600;
}

.primary-button.compact {
  width: max-content;
  min-height: 34px;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.icon-button,
.send-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
}

.icon-button.tiny {
  width: 28px;
  height: 28px;
}

.icon-button i,
.icon-button .local-icon,
.send-button i,
.send-button .local-icon {
  width: 17px;
  height: 17px;
}

.send-button {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.thread-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.thread-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  overflow: auto;
  padding: 18px 20px;
}

.ledger-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 980px;
  padding: 2px 2px 8px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.ledger-header h2 {
  margin: 3px 0 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.25;
}

.ledger-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.ledger-summary span,
.item-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.ledger-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  max-width: 980px;
  min-width: 0;
}

.item-rail {
  display: grid;
  justify-items: center;
  position: relative;
}

.item-rail::after {
  content: "";
  position: absolute;
  top: 28px;
  bottom: -12px;
  width: 1px;
  background: var(--line);
}

.ledger-item:last-child .item-rail::after {
  display: none;
}

.item-node {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--teal);
  background: var(--panel-strong);
  z-index: 1;
}

.item-node i,
.item-node .local-icon {
  width: 13px;
  height: 13px;
}

.ledger-item.waiting .item-node {
  color: var(--amber);
  border-color: var(--amber);
  background: var(--amber-soft);
}

.ledger-item.completed .item-node {
  color: var(--green);
}

.ledger-item.failed .item-node,
.ledger-item.cancelled .item-node {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-soft);
}

.item-card {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--panel), transparent 18%);
  box-shadow: none;
}

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

.item-title-row {
  min-width: 0;
}

.item-title-row h3 {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 620;
  line-height: 1.35;
}

.item-type {
  color: var(--teal);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

.item-status {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 10.5px;
  font-weight: 650;
  white-space: nowrap;
}

.item-status.waiting,
.item-status.started,
.item-status.delta {
  color: var(--amber);
  background: var(--amber-soft);
}

.item-status.failed,
.item-status.cancelled {
  color: var(--red);
  background: var(--red-soft);
}

.item-card p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 560;
}

.item-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.message {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  max-width: 920px;
}

.message.user {
  align-self: flex-end;
  grid-template-columns: minmax(0, 1fr) 28px;
}

.avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: var(--teal);
  font-size: 11px;
  font-weight: 650;
}

.message.user .avatar {
  grid-column: 2;
  background: var(--violet);
}

.bubble {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--panel), transparent 16%);
  line-height: 1.48;
}

.message.user .bubble {
  grid-column: 1;
  grid-row: 1;
  background: var(--teal-soft);
}

.bubble h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 620;
}

.bubble p {
  margin: 0 0 8px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.plan-list,
.audit-list,
.doc-listing {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.plan-list li,
.audit-list li,
.doc-listing li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--muted);
  font-size: 12px;
}

.confirm-card {
  margin-top: 12px;
  border: 1px solid var(--amber);
  border-radius: 8px;
  background: var(--amber-soft);
  overflow: hidden;
}

.confirm-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--amber);
}

.confirm-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--amber);
  font-weight: 620;
}

.confirm-card-title i,
.confirm-card-title .local-icon {
  width: 16px;
  height: 16px;
}

.diff-box {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--amber);
  border-radius: 8px;
  color: var(--amber);
  background: var(--amber-soft);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.diff-box.compact {
  max-height: 190px;
  margin-top: 10px;
}

.approval-gate {
  margin-top: 12px;
  min-width: 0;
  border: 1px solid var(--amber);
  border-radius: 8px;
  background: var(--amber-soft);
  overflow: hidden;
}

.approval-gate-head,
.diff-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--amber);
}

.approval-copy {
  padding: 11px 12px 0;
  color: var(--amber);
  font-size: 13px;
  line-height: 1.55;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 12px 12px;
}

.danger-button,
.ghost-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
}

.danger-button {
  border: 1px solid var(--red);
  color: var(--red);
  background: var(--panel);
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
}

.quick-actions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 22px 0;
}

.quick-actions button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
  padding: 0 12px;
}

.composer {
  display: grid;
  gap: 8px;
  padding: 14px 22px 18px;
}

.composer-toolbar,
.composer-row,
.attachment-tray {
  display: flex;
  align-items: center;
  min-width: 0;
}

.composer-toolbar {
  gap: 8px;
  flex-wrap: wrap;
}

.composer-mode-switch {
  flex: 0 0 auto;
}

.composer-mode-switch button {
  min-width: 88px;
}

.composer-row {
  gap: 10px;
}

.hidden-file-input {
  display: none;
}

.composer-toolbar select {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  padding: 0 10px;
}

.voice-output-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  font-size: 12px;
  font-weight: 600;
}

.voice-output-toggle input {
  width: 14px;
  height: 14px;
}

.attachment-tray {
  gap: 6px;
  flex-wrap: wrap;
  min-height: 0;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: min(280px, 100%);
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  font-size: 12px;
}

.attachment-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip button {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.composer input,
.dept-form input,
.table-edit-form textarea,
.settings-form input,
.settings-form select,
.settings-form textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: var(--panel);
  padding: 0 12px;
}

.settings-form textarea,
.table-edit-form textarea {
  min-height: 92px;
  padding: 10px 12px;
  resize: vertical;
}

.table-edit-form textarea {
  min-height: 118px;
  line-height: 1.5;
}

.composer input:focus,
.composer-toolbar select:focus,
.dept-form input:focus,
.table-edit-form textarea:focus,
.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(39, 107, 74, 0.12);
}

.execution-dock {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
}

.dock-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 560;
}

.execution-steps {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.exec-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel), transparent 26%);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.exec-step.active {
  color: var(--teal);
  border-color: var(--teal);
  background: var(--teal-soft);
}

.exec-step.success {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-soft);
}

.exec-step.waiting {
  color: var(--amber);
  border-color: var(--amber);
  background: var(--amber-soft);
}

.exec-step i,
.exec-step .local-icon {
  width: 12px;
  height: 12px;
}

.context-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  position: relative;
  border-left: 1px solid var(--line);
  background: var(--panel);
  transition: width 180ms ease, opacity 180ms ease;
}

.app-shell.context-collapsed {
  grid-template-columns: var(--sidebar-width) minmax(360px, 1fr) 0;
}

.app-shell.context-collapsed .context-panel {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

.context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.context-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.context-tabs button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 560;
}

.context-tabs button.active {
  color: var(--green);
  background: var(--green-soft);
}

.context-content {
  overflow: auto;
  padding: 16px;
}

.context-resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  width: 8px;
  cursor: col-resize;
  z-index: 2;
}

.context-resize-handle::after {
  content: "";
  position: absolute;
  top: 46%;
  left: 3px;
  width: 2px;
  height: 56px;
  border-radius: 999px;
  background: transparent;
  transition: background 120ms ease;
}

.context-resize-handle:hover::after,
body.resizing-context .context-resize-handle::after {
  background: var(--green);
}

.diff-panel-card {
  margin-bottom: 12px;
  border: 1px solid var(--amber);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.diff-panel-card .diff-box {
  border: 0;
  border-radius: 0;
}

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

.runtime-card {
  min-height: 96px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--panel), transparent 16%);
}

.runtime-card strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  font-weight: 620;
}

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

.runtime-label {
  color: var(--teal);
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
}

.dashboard-grid,
.finance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary-card,
.finance-card,
.result-row,
.plugin-card,
.automation-row,
.command-row {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.summary-card {
  display: grid;
  align-content: start;
  gap: 8px;
}

.summary-card strong,
.finance-card strong {
  font-weight: 620;
  line-height: 1.35;
}

.finance-card p,
.plugin-card p,
.automation-row p,
.result-row p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.finance-card.warn {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.finance-card.red {
  border-color: var(--red);
  background: var(--red-soft);
}

.command-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  margin-bottom: 8px;
}

.business-summary-grid {
  margin-bottom: 16px;
}

.business-chain {
  display: grid;
  gap: 8px;
}

.business-chain-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.business-chain-row strong {
  font-weight: 560;
  line-height: 1.45;
}

.strategy-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.search-results,
.plugin-list,
.automation-list {
  display: grid;
  gap: 10px;
}

.todo-list,
.finance-report-list,
.report-list {
  display: grid;
  gap: 10px;
}

.finance-report-list,
.report-list {
  margin-top: 14px;
}

.finance-report-list h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 620;
}

.finance-report-row,
.report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

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

.plugin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.plugin-head h3 {
  margin: 7px 0 0;
  font-size: 14px;
  font-weight: 620;
}

.plugin-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 560;
}

.plugin-stats span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.plugin-stats i,
.plugin-stats .local-icon {
  width: 13px;
  height: 13px;
}

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

.comment-list {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.comment-list div {
  padding: 8px;
  border-radius: 8px;
  background: var(--panel-strong);
}

.automation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.doc-section {
  margin-bottom: 16px;
}

.doc-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 620;
}

.doc-section p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.52;
}

.metric-row,
.task-row,
.meeting-row,
.okr-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 8px;
}

.metric-row {
  grid-template-columns: minmax(120px, 1fr) 72px 72px;
  align-items: center;
}

.task-row {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.compact-task-row {
  grid-template-columns: minmax(180px, 1fr) auto;
}

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

.company-todo-list {
  gap: 12px;
}

.company-todo-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.company-todo-head,
.todo-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.company-todo-head {
  justify-content: space-between;
}

.todo-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 220px;
}

.todo-evidence {
  margin-top: 6px !important;
  font-size: 12px;
  color: var(--text) !important;
}

.meeting-row {
  grid-template-columns: 80px 1fr;
}

.okr-row {
  grid-template-columns: 70px 1fr;
}

.okr-row.wide {
  grid-template-columns: minmax(150px, 1fr) minmax(160px, 0.85fr);
}

.row-label {
  color: var(--muted);
  font-size: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 620;
}

.badge.warn {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.info {
  color: var(--blue);
  background: var(--blue-soft);
}

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

.flow-map {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.flow-layer {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.flow-node {
  min-height: 48px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 12px;
  text-align: center;
}

.flow-node.strong {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
  font-weight: 620;
}

.methodology-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.methodology-list div {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.48;
}

.methodology-list strong {
  color: var(--ink);
  font-weight: 620;
}

.compact-section {
  margin: 14px 0 0;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.data-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.data-table.compact {
  min-width: 720px;
}

.target-table {
  min-width: 1380px;
}

.monitor-table {
  min-width: 1260px;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  line-height: 1.42;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--ink);
  background: var(--panel-strong);
  font-weight: 620;
  white-space: nowrap;
}

.data-table td {
  color: var(--muted);
}

.table-cell-edit {
  display: block;
  width: 100%;
  min-width: 72px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  line-height: 1.42;
  text-align: left;
  cursor: pointer;
}

.table-cell-edit:hover,
.table-cell-edit:focus-visible {
  color: var(--ink);
  outline: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

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

.domain-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.domain-card-head,
.module-line,
.market-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.domain-layer {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.module-line {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
}

.module-line strong {
  color: var(--ink);
}

.empty-state {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
}

.compact-empty {
  border: 0;
  background: transparent;
}

.market-empty {
  grid-column: 1 / -1;
}

.meeting-category-row,
.market-category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.marketplace-main {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 1180px;
}

.market-ledger {
  max-width: none;
}

.market-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.market-search {
  margin: 0;
}

.market-category-row button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel);
  font-size: 12px;
  font-weight: 560;
}

.market-category-row button.active {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-soft);
}

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

.market-execution-ledger {
  display: grid;
  gap: 14px;
  padding-top: 4px;
}

.market-card {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 260px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.market-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
  line-height: 1.25;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 37, 34, 0.34);
  z-index: 20;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(900px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal.small {
  width: min(460px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.settings-session-banner {
  display: grid;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.settings-session-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-session-main strong {
  font-weight: 620;
}

.settings-session-main span,
.settings-session-banner p {
  color: var(--muted);
  font-size: 12px;
}

.settings-session-banner p {
  margin: 0;
}

.settings-block {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.block-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.block-heading i,
.block-heading .local-icon {
  width: 18px;
  height: 18px;
  color: var(--green);
}

.block-heading h3 {
  margin: 0;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.setting-row.vertical {
  display: grid;
}

.setting-row strong {
  color: var(--ink);
  text-align: right;
}

.setting-subhead {
  padding-top: 4px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

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

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

.user-admin-form label:nth-of-type(7),
.user-admin-form .checkbox-label,
.user-admin-form .inline-actions {
  grid-column: 1 / -1;
}

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

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

.backup-retention-form .inline-actions {
  grid-column: 1 / -1;
}

.audit-filter-form .inline-actions {
  grid-column: 1 / -1;
}

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

.settings-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 560;
}

.settings-form .checkbox-label {
  display: flex;
  align-items: center;
}

.settings-form .checkbox-label input {
  width: 16px;
  height: 16px;
}

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

.compact-list {
  max-height: 320px;
  overflow: auto;
}

.setting-list-row,
.setting-status {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.setting-status {
  color: var(--muted);
}

.help-tip {
  position: relative;
  display: inline-grid;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  place-items: center;
  overflow: visible;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: transparent !important;
  background: transparent;
  font-size: 0;
  line-height: 1;
  vertical-align: middle;
}

.help-tip::before {
  content: "i";
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
}

.help-tip:hover::after,
.help-tip:focus-visible::after {
  content: attr(data-help);
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 50;
  width: max-content;
  max-width: min(340px, calc(100vw - 40px));
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
}

.settings-session-banner p.help-tip,
.setting-status.help-tip,
.empty-state.help-tip {
  margin: 0;
}

.settings-session-banner p.help-tip {
  justify-self: start;
}

.tool-row {
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
}

.lark-preflight-row {
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
}

.lark-login-card a {
  color: var(--accent);
  overflow-wrap: anywhere;
  font-size: 12px;
}

.lark-qr-ascii {
  max-height: 220px;
  overflow: auto;
  margin: 4px 0 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--panel-strong);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 7px;
  line-height: 1;
  white-space: pre;
}

.session-row,
.backup-row,
.readiness-row,
.ops-alert-row,
.review-row {
  grid-template-columns: minmax(160px, 1fr) auto;
  align-items: center;
}

.tool-row span,
.lark-preflight-row span,
.audit-row span,
.session-row span,
.backup-row span,
.readiness-row span,
.ops-alert-row span,
.review-row span {
  color: var(--muted);
  font-size: 12px;
}

.ops-alert-row .badge,
.readiness-row .badge {
  justify-self: end;
}

.review-actions {
  justify-content: flex-start;
  min-width: 0;
  margin-top: 10px;
}

.tool-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.permission-table,
.model-route-table {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(160px, 1.2fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  font-size: 13px;
}

.permission-table div,
.model-route-table div {
  padding: 9px;
  border-bottom: 1px solid var(--line);
}

.permission-template-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.permission-template-cell span {
  min-width: 0;
}

.permission-table div:nth-child(1),
.permission-table div:nth-child(2),
.model-route-table div:nth-child(1),
.model-route-table div:nth-child(2) {
  color: #fff;
  background: var(--teal);
  font-weight: 620;
}

.dept-form,
.table-edit-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dept-form label,
.table-edit-form label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.dept-form p,
.table-edit-form p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: minmax(230px, var(--sidebar-width)) minmax(0, 1fr);
  }

  .context-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 92vw);
    z-index: 10;
    box-shadow: var(--shadow);
  }

  .app-shell.context-collapsed {
    grid-template-columns: minmax(230px, var(--sidebar-width)) minmax(0, 1fr);
  }

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

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

  .setup-actions {
    grid-template-columns: 1fr;
  }

  .app-shell,
  .app-shell.context-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .workspace-header,
  .header-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .recovery-actions {
    width: 100%;
  }

  .header-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
  }

  .recovery-actions {
    width: auto;
    justify-content: flex-start;
  }

  .mobile-settings-button {
    display: inline-grid;
  }

  .ledger-header,
  .item-card-head,
  .diff-title,
  .approval-gate-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .backup-retention-form,
  .user-admin-form {
    grid-template-columns: 1fr;
  }

  .context-panel {
    width: 100vw;
   }

  .execution-dock {
    grid-template-columns: 1fr;
  }

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

  .runtime-grid,
  .dashboard-grid,
  .finance-grid,
  .business-chain-row,
  .metric-row,
  .task-row,
  .meeting-row,
  .okr-row,
  .okr-row.wide,
  .command-row,
  .automation-row {
    grid-template-columns: 1fr;
  }

  .plugin-head {
    flex-direction: column;
  }

  .left-controls,
  .market-toolbar,
  .market-grid {
    grid-template-columns: 1fr;
  }

  .data-table {
    font-size: 12px;
  }
}
