:root {
  --ink: #172a46;
  --canvas: #f1f5fb;
  --surface-tint: #f6f9fe;
  --border: #c9d7eb;
  --accent-hover: #1945ae;
  --shadow: 0 2px 4px rgb(20 47 90 / 4%), 0 8px 26px rgb(20 47 90 / 5%);
  --topbar-height: 62px;
  --gutter: 22px;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
  color: var(--ink);
  background: var(--canvas);
  --line: #dee7f3;
  --muted: #52637c;
  --accent: #2456cc;
  --soft: #e9f1ff;
  --sidebar: #102344;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  font-size: 14px;
  line-height: 1.5;
}
::selection { background: #dce8ff; color: var(--ink); }
input[type="checkbox"] { accent-color: var(--accent); }
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
select {
  cursor: pointer;
}
button:disabled,
select:disabled {
  opacity: 0.55;
  cursor: wait;
}
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #3972e8;
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
svg {
  width: 18px;
  height: 18px;
  display: block;
  flex: none;
}
button {
  border: 0;
  background: none;
  color: inherit;
}
small {
  display: block;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  background: linear-gradient(165deg, #142b50 0%, var(--sidebar) 65%);
  color: #eaf1ff;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 4px 35px;
}
.brand-icon {
  background: linear-gradient(145deg, #4b83ff, #2856cf);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 28%), 0 4px 12px rgb(4 17 42 / 32%);
  color: #fff;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 11px;
  display: grid;
  place-items: center;
}
.brand-icon svg {
  width: 20px;
  height: 20px;
}
.brand strong {
  font-size: 15px;
  white-space: nowrap;
}
.brand small {
  font-size: 9px;
  letter-spacing: 0.16em;
  color: #b2c5e4;
  margin-top: 2px;
}
.workspace-nav { display: flex; flex-direction: column; min-height: 0; }
#workspace-assistants { min-height: 0; overflow: auto; scrollbar-width: thin; }
.skill-nav .nav-item { width: 100%; }
.nav-label {
  margin: 0 11px 10px;
  font-size: 11px;
  color: #a9bedf;
  letter-spacing: 0.06em;
}
.nav-item {
  display: flex;
  align-items: center;
  text-align: left;
  gap: 9px;
  min-height: 42px;
  padding: 0 11px;
  border-radius: 8px;
  color: #dce8fc;
  margin-bottom: 4px;
  font-size: 14px;
}
.nav-item svg { width: 16px; height: 16px; }
.sidebar .nav-item:focus-visible { outline-color: #8eb8ff; outline-offset: -3px; }
.nav-item:hover { background: #203b65; color: #fff; }
.nav-item.active { background: #254881; box-shadow: inset 0 0 0 1px #3b62a0; color: #fff; font-weight: 650; }
#workspace-assistants .nav-item { width: 100%; min-width: 0; }
.workspace-assistant-item > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-divider { height: 1px; margin: 10px 6px; background: #304565; }
#add-assistant { color: #c4d6f3; }
.sidebar-footer {
  margin-top: auto;
  padding: 14px 8px 2px;
  border-top: 1px solid #304565;
  font-size: 12px;
}
.demo-mark {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #c4d6f3;
  margin-bottom: 12px;
  font-size: 11px;
}
.demo-mark span {
  height: 7px;
  width: 7px;
  background: #87b7ff;
  border-radius: 50%;
}
.sidebar-footer label {
  display: block;
  margin-bottom: 7px;
  color: #c4d6f3;
}
.sidebar-footer select {
  width: 100%;
  background: #1a3258;
  color: #eef4ff;
  border: 1px solid #46648f;
  border-radius: 8px;
  padding: 8px;
}
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 var(--gutter);
  font-size: 13px;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}
.breadcrumb svg { width: 13px; height: 13px; color: #657993; }
.breadcrumb strong {
  color: var(--ink);
}
.scope {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.scope label {
  color: var(--muted);
}
.scope select,
.month {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: var(--surface-tint);
  color: var(--ink);
}
.scope select { min-width: 0; max-width: min(35vw, 280px); }
.scope #merge-open { white-space: nowrap; font-size: 12px; padding: 5px 8px; min-height: 34px; }
.month {
  white-space: nowrap;
  width: 136px;
  max-width: 40vw;
  min-width: 0;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  grid-template-rows: minmax(0, 1fr);
  height: calc(100dvh - var(--topbar-height));
  gap: 16px;
  padding: var(--gutter);
  max-width: 1650px;
  margin: 0 auto;
}
.conversation,
.result {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  min-width: 0;
  min-height: 0;
  box-shadow: var(--shadow);
}
.conversation {
  display: flex;
  flex-direction: column;
}
.assistant-header,
.result-header {
  display: flex;
  flex: none;
  align-items: center;
  gap: 11px;
  padding: 15px 19px;
  border-bottom: 1px solid var(--line);
  min-height: 78px;
}
.assistant-header h1,
.result-header h2 {
  font-size: 19px;
  line-height: 1.4;
  margin: 0;
}
.assistant-header p {
  font-size: 12px;
  color: var(--muted);
  margin: 3px 0 0;
}
.assistant-heading { flex: 1 1 0; min-width: 0; }
.assistant-title-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.assistant-title-line h1 { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-header p { overflow-wrap: anywhere; }
.assistant-edit {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  color: var(--accent);
}
.assistant-edit:hover { background: var(--soft); }
.assistant-edit svg { width: 15px; height: 15px; }
.assistant-header-actions { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.assistant-header-actions #draft-from-chat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
}
#draft-from-chat svg { width: 14px; height: 14px; }
.assistant-icon,
.welcome-icon,
.result-icon {
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--accent);
  border-radius: 11px;
  width: 41px;
  height: 41px;
  flex: none;
}
.engine {
  font-size: 11px;
  white-space: nowrap;
  color: #345788;
  background: var(--soft);
  border-radius: 20px;
  padding: 5px 8px;
}
.messages {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 22px clamp(16px, 2vw, 28px) 18px;
  overscroll-behavior-y: contain;
}
.welcome {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: radial-gradient(ellipse at 100% 0%, #e9f1ff, transparent 68%), var(--surface-tint);
  padding: clamp(16px, 2.4vw, 32px);
  margin-bottom: 18px;
}
.welcome-icon {
  width: 52px;
  height: 52px;
  margin-bottom: 15px;
  background: #fff;
  border: 1px solid #dbe7fa;
  box-shadow: 0 2px 8px rgb(27 65 125 / 6%);
}
.welcome-icon svg {
  width: 24px;
  height: 24px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.07em;
  color: #48638a;
  margin-bottom: 5px;
  font-weight: 650;
}
.welcome h2 {
  font-size: clamp(23px, 2.25vw, 32px);
  margin: 4px 0 9px;
  letter-spacing: -0.035em;
}
.welcome p,
.empty p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
  max-width: 35em;
}
.quick-icon {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 9px;
  flex: none;
}
.icon-tint {
  background: var(--soft);
  color: var(--accent);
}
.bubble {
  width: fit-content;
  max-width: 94%;
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 4px 12px 12px;
  background: #f0f4fa;
  font-size: 14px;
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble.user {
  margin-left: auto;
  background: #2355c8;
  color: #fff;
  border-radius: 12px 4px 12px 12px;
}
.bubble.error {
  background: #faece5;
  color: #873d26;
}
.message-skill {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 7px;
  padding: 3px 7px;
  border: 1px solid rgb(255 255 255 / 40%);
  border-radius: 6px;
  background: rgb(255 255 255 / 12%);
  font-size: 11px;
  font-weight: 650;
}
.message-memory {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
}
.turn-progress {
  width: min(100%, 410px);
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-tint);
  font-size: 13px;
}
.turn-progress-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 12px; }
.turn-progress-head span { margin-left: auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.turn-progress-detail { margin-top: 4px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.turn-progress-detail:empty { display: none; }
.turn-progress-track {
  height: 3px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--soft);
}
.turn-progress-track::after {
  display: block;
  width: 32%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: turn-progress-slide 1.6s ease-in-out infinite alternate;
  content: '';
}
.turn-progress.finished { background: #fff; padding-block: 8px; }
@keyframes turn-progress-slide {
  to { transform: translateX(215%); }
}
@media (prefers-reduced-motion: reduce) {
  .turn-progress-track::after { animation: none; }
}
.compose-wrap {
  position: relative;
  flex: none;
  padding: 12px clamp(14px, 1.5vw, 22px) 12px;
  border-top: 1px solid var(--line);
  background: #fff;
  border-radius: 0 0 14px 14px;
}
.choose-skill {
  min-width: 66px;
  min-height: 39px;
  padding: 0 6px;
  border-radius: 7px;
  background: var(--soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.choose-skill:hover,
.choose-skill[aria-expanded="true"] {
  background: #dbe8ff;
}
.skill-picker {
  position: absolute;
  z-index: 3;
  left: 18px;
  right: 18px;
  bottom: calc(100% + 6px);
  max-width: 410px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 26px #182e551e;
}
#skill-options { max-height: min(250px, 34dvh); overflow: auto; }
.skill-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 9px;
  font-size: 14px;
}
.skill-picker-head span,
.skill-option small,
.skill-empty {
  color: var(--muted);
  font-size: 12px;
}
#skill-search {
  width: 100%;
  padding: 8px;
  margin-bottom: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 13px;
}
.skill-option {
  width: 100%;
  text-align: left;
  padding: 9px;
  border-radius: 7px;
  font-size: 13px;
}
.skill-option:hover,
.skill-option:focus-visible {
  background: var(--soft);
}
.skill-option small {
  display: block;
  margin-top: 4px;
  line-height: 1.5;
}
.mounted-skill {
  display: flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 7px;
  padding: 3px 4px 3px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
}
.mounted-skill button {
  min-width: 26px;
  min-height: 24px;
  border-radius: 5px;
  font-size: 16px;
}
.mounted-skill button:hover {
  background: #dbe8ff;
}
.context {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}
.compose {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
  gap: 5px;
}
.compose:focus-within { border-color: #7195ed; box-shadow: 0 0 0 3px #e7efff; }
.compose input {
  min-width: 0;
  flex: 1;
  border: 0;
  padding: 6px 7px;
  color: var(--ink);
  font-size: 14px;
}
.compose input::placeholder {
  color: #60728b;
}
.send {
  background: var(--accent);
  color: #fff;
  flex: none;
  width: 39px;
  height: 39px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.send:hover {
  background: var(--accent-hover);
}
.compose-hint {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  margin-top: 7px;
}
.result {
  display: flex;
  flex-direction: column;
}
.result-header {
  justify-content: space-between;
  flex-wrap: wrap;
}
.result-heading { display: flex; align-items: center; gap: 10px; min-width: 0; }
.result-heading .eyebrow { margin-bottom: 2px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.export {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  white-space: nowrap;
}
.export:hover {
  background: var(--soft);
}
.export svg {
  width: 15px;
  height: 15px;
}
.result-sheet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 16px 0;
  background: var(--surface-tint);
  border-bottom: 1px solid var(--line);
}
.result-sheet-tabs button {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.result-sheet-tabs button:hover {
  background: var(--soft);
}
.result-sheet-tabs button[aria-selected="true"] {
  color: var(--accent);
  background: #fff;
  border-color: var(--line);
  border-bottom-color: var(--accent);
  font-weight: 650;
}
.result-sheet-tabs button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}
.result-body {
  padding: 17px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}
.empty {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 20px 8px;
}
.empty strong { font-size: 16px; }
.empty-icon {
  display: grid;
  place-items: center;
  color: #3f69ad;
  width: 64px;
  height: 64px;
  border-radius: 17px;
  background: var(--soft);
  margin-bottom: 4px;
}
.empty-icon svg {
  width: 30px;
  height: 30px;
}
.empty p {
  font-size: 13px;
  max-width: 260px;
}
.metrics {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 8px;
}
.metric {
  background: var(--surface-tint);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 10px;
}
.metric:first-child { background: var(--soft); border-color: #d8e6ff; }
.metric span,
.batch-meta {
  font-size: 11px;
  color: var(--muted);
}
.metric strong {
  display: block;
  font-size: clamp(18px, 2vw, 24px);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.metric:first-child strong {
  color: var(--accent);
}
.batch-meta {
  padding: 10px 0;
  line-height: 1.5;
}
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.tabs button {
  font-size: 13px;
  padding: 8px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tabs button[aria-pressed="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 650;
}
.query-trace {
  margin: 12px 0;
  font-size: 0.875rem;
}

.query-trace summary {
  cursor: pointer;
}

.query-trace pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sales-report #query-rows td { white-space: nowrap; }
.sales-report #query-rows td:last-child {
  min-width: 230px;
  white-space: normal;
  text-align: left;
}
#result-notes-rows td:first-child { white-space: nowrap; }
#result-notes-rows td:last-child { overflow-wrap: anywhere; }

.table-frame {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
}
table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  font-size: 13px;
}
th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}
th {
  color: var(--muted);
  background: var(--surface-tint);
  font-weight: 600;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-tint); }
th:last-child,
td:last-child {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
td small {
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
}
.row-select {
  display: block;
  text-align: left;
  font-weight: 650;
  padding: 3px 0;
  color: var(--accent);
  min-width: 53px;
}
.row-select:hover {
  text-decoration: underline;
}
tr.selected {
  background: var(--soft);
}
.status {
  display: inline-block;
  font-size: 10px;
  border-radius: 20px;
  white-space: nowrap;
  padding: 3px 6px;
  background: #e5f4ec;
  color: #255c45;
}
.status.pending {
  background: #fbefda;
  color: #754e12;
}
.detail {
  border: 1px solid var(--line);
  background: var(--surface-tint);
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
}
.detail h3 {
  font-size: 14px;
  margin: 0 0 6px;
}
.detail p {
  margin: 6px 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.detail .evidence {
  color: var(--ink);
}
.detail label {
  display: block;
  font-size: 12px;
  margin: 10px 0 5px;
}
.detail textarea {
  width: 100%;
  min-height: 48px;
  resize: vertical;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
}
.detail-actions {
  display: flex;
  gap: 7px;
  margin-top: 7px;
}
.detail button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  padding: 6px 8px;
  color: var(--accent);
  font-size: 12px;
}
.detail button:hover {
  background: var(--soft);
}
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100% - 32px));
  background: var(--sidebar);
  color: #fff;
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 13px;
  z-index: 10;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.reconciliation {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--soft);
  color: #345788;
  font-size: 12px;
  line-height: 1.5;
}
.lineage {
  overflow-wrap: anywhere;
  white-space: pre-line;
}
@media (max-width: 1120px) {
  :root { --gutter: 16px; }
  body {
    grid-template-columns: 190px minmax(0, 1fr);
  }
  .layout {
    padding: 13px;
    gap: 12px;
  }
  .sidebar {
    padding-left: 10px;
    padding-right: 10px;
  }
  .assistant-header,
  .result-header {
    padding: 14px 12px;
  }
  .messages {
    padding-left: 13px;
    padding-right: 13px;
  }
  .result-body {
    padding: 11px;
  }
}
@media (max-width: 960px) {
  :root { --topbar-height: 54px; }
  body {
    display: block;
  }
  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 10px;
    padding: 12px var(--gutter) 8px;
  }
  .brand {
    margin: 0 auto 0 0;
  }
  .brand small,
  .nav-label,
  .sidebar-footer label,
  .demo-mark {
    display: none;
  }
  .sidebar-footer {
    padding: 0;
    margin: 0;
    border: 0;
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }
  .sidebar-footer #account-role { display: none; }
  .account-actions { justify-content: flex-end; }
  .workspace-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }
  #workspace-assistants { display: flex; gap: 5px; max-width: 100%; }
  .sidebar .nav-item { margin: 0; min-height: 42px; white-space: nowrap; }
  #workspace-assistants .nav-item { width: auto; min-width: max-content; }
  #workspace-assistants .nav-item > span:last-child { max-width: min(44vw, 18ch); }
  #add-assistant { flex: none; }
  .skill-nav { grid-column: 1 / -1; display: flex; gap: 5px; border-top: 1px solid #304565; padding-top: 5px; }
  .skill-nav .nav-item { width: auto; }
  .workspace-divider { display: none; }
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
  }
  .conversation {
    height: clamp(455px, 74dvh, 650px);
  }
  .result {
    min-height: 320px;
    max-height: min(720px, 85dvh);
  }
  .result-body, .messages {
    overscroll-behavior-y: auto;
  }
  .empty {
    min-height: 240px;
  }
  .scope label {
    display: none;
  }
}
@media (max-width: 410px) {
  .breadcrumb-root, .breadcrumb [data-icon] { display: none; }
  .layout {
    padding: 10px;
  }
  .conversation { height: clamp(420px, calc(100dvh - 250px), 620px); }
  #account-name { display: block; max-width: 39vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .scope {
    gap: 5px;
  }
  .scope select { max-width: min(57vw, 280px); }
  .month,
  .scope select {
    padding: 6px;
  }
  .topbar {
    padding: 0 10px;
  }
  .assistant-header { gap: 7px; }
  .assistant-icon { width: 34px; height: 34px; }
  .assistant-header-actions #draft-from-chat { gap: 4px; padding-inline: 6px; }
  th, td { padding-inline: 6px; }
}

.auth-view {
  grid-column: 1 / -1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(12px, 4vw, 44px);
  background: radial-gradient(ellipse at 80% 0%, #dce9ff, transparent 60%), var(--canvas);
}
.auth-shell {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  width: min(100%, 880px);
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 70px rgb(25 55 109 / 13%);
  overflow: hidden;
}
.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  padding: clamp(24px, 4vw, 42px);
  background:
    radial-gradient(circle at 100% 100%, rgb(87 144 255 / 34%), transparent 57%),
    linear-gradient(150deg, #142951, #1a3e87);
  color: #fff;
}
.auth-brand .brand { margin: 0; }
.auth-intro { margin: 40px 0 18px; }
.auth-intro > p { margin: 0 0 8px; color: #c0d6ff; font-weight: 600; }
.auth-intro > strong { font-size: clamp(25px, 4vw, 42px); line-height: 1.26; }
.auth-intro ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 25px 0 0; padding: 0; list-style: none; }
.auth-intro li {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border: 1px solid #5a7eb8;
  border-radius: 6px;
  background: rgb(255 255 255 / 8%);
  color: #edf4ff;
  font-size: 12px;
}
.auth-intro svg { width: 14px; height: 14px; }
.auth-card, .admin-card, .merge-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
}
.admin-card, .merge-panel { box-shadow: var(--shadow); }
.auth-card {
  align-self: center;
  min-width: 0;
  padding: clamp(22px, 5vw, 52px);
  border: 0;
}
.auth-card h1 { margin: 0; font-size: 27px; }
.auth-description { margin: 5px 0 22px; color: var(--muted); }
.admin-header h1 { margin: 8px 0 20px; font-size: 26px; }
.auth-card label, .admin-form > label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}
.auth-card label { margin-bottom: 15px; font-weight: 600; }
.auth-card input, .admin-form input:not([type="checkbox"]), .admin-form select {
  min-width: 0;
  min-height: 38px;
  padding: 8px 10px;
  color: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
}
.primary-button, .secondary-button {
  justify-self: start;
  min-height: 38px;
  padding: 7px 13px;
  border-radius: 7px;
  font-weight: 600;
}
.primary-button { background: var(--accent); color: white; }
.primary-button:hover { background: var(--accent-hover); }
.secondary-button { border: 1px solid var(--border); color: var(--accent); background: #fff; }
.secondary-button:hover { background: var(--soft); }
.auth-card input, .auth-card .primary-button { min-height: 44px; }
.auth-card .primary-button { width: 100%; margin-top: 3px; }
@media (max-width: 630px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr); width: min(100%, 430px); min-height: 0; }
  .auth-intro { margin: 18px 0 0; }
  .auth-intro > strong, .auth-intro ul { display: none; }
  .auth-intro > p { margin: 0; }
}
.form-error { margin: 0; color: #a32d23; font-size: 13px; }
.form-error:not(:empty) { margin-top: 8px; }
.account-actions, .form-actions, .admin-header, .account-permissions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.account-actions button { padding: 5px 0; color: #c5d6f2; font-size: 12px; }
.account-actions button:hover { color: #fff; text-decoration: underline; }
#account-role { margin-top: 4px; color: #b2c5e4; }
.admin-panel { padding: 18px; }
.admin-header { justify-content: space-between; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.admin-card h2 { margin: 0 0 12px; font-size: 19px; }
.admin-card h3 { margin: 0; font-size: 15px; }
.admin-hint { font-size: 13px; color: var(--muted); }
.admin-form {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 15px;
  margin-top: 15px;
}
.admin-form fieldset { min-width: 0; margin: 0; border: 1px solid var(--line); border-radius: 8px; }
.grant-options { display: flex; gap: 8px 14px; flex-wrap: wrap; }
.account-data-mode { margin-bottom: 8px; }
#account-data-all-hint { margin: 0; }
.position-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
#grant-options { display: grid; max-height: 190px; overflow: auto; padding: 8px 2px 3px; }
#grant-field > label { display: grid; gap: 5px; font-size: 13px; }
#account-assistant-access > label { display: flex; align-items: center; gap: 5px; font-size: 13px; margin-bottom: 8px; }
#account-admin-access { margin: 0; }
.grant-options label, .account-permissions label, .admin-form .inline-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
}
.account-list, .organization-list { display: grid; gap: 4px; max-height: 265px; overflow: auto; }
.account-list button, .organization-list div {
  padding: 7px 9px;
  text-align: left;
  border-radius: 6px;
  background: var(--surface-tint);
  overflow-wrap: anywhere;
  font-size: 13px;
}
.account-list button[aria-pressed="true"] { background: var(--soft); color: var(--accent); font-weight: 600; }
.no-workspace, .merge-panel { margin: 14px; }
.merge-panel { display: grid; gap: 14px; max-width: 820px; padding: 20px; }
.merge-panel h1 { margin: 0; font-size: 22px; }
.merge-panel .admin-hint { margin: 0; }
@media (max-width: 850px) {
  .admin-grid { grid-template-columns: 1fr; }
}
.admin-form textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; resize: vertical; }

#main:has(#admin-panel:not([hidden])) .topbar { display: none; }
.admin-panel { padding: clamp(14px, 2vw, 28px); }
.admin-header { margin-bottom: 20px; }
.admin-header h1 { margin: 5px 0 0; }
.admin-shell {
  display: grid;
  grid-template-columns: minmax(148px, 184px) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}
.admin-nav {
  display: grid;
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}
.admin-nav button {
  min-height: 44px;
  border-radius: 7px;
  padding: 8px 12px;
  text-align: left;
  font-size: 14px;
}
.admin-nav button span {
  margin-right: 5px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.admin-nav button:hover { background: var(--surface-tint); }
.admin-nav button[aria-current="page"] {
  background: var(--soft);
  color: var(--accent);
  font-weight: 700;
}
.admin-nav-label {
  padding: 12px 12px 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.memory-card { max-width: 1020px; padding: clamp(16px, 2.25vw, 32px); }
.memory-heading h2 { margin: 6px 0 8px; font-size: 24px; }
.memory-heading p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 14px; }
.memory-form { gap: 16px; }
.memory-form label, .memory-selection label { min-width: 0; }
.memory-form :is(textarea, select), .memory-fields :is(input, select) {
  width: 100%;
  min-height: 44px;
  font-size: 16px;
  line-height: 1.5;
}
.memory-form textarea { color: inherit; }
.memory-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.memory-selection { margin-top: 16px; }
.memory-selection select {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: inherit;
  background: #fff;
}
.memory-fields label, .metric-editor > label {
  display: grid;
  gap: 5px;
  font-size: 14px;
}
.metric-editor { display: grid; gap: 12px; padding: 12px; }
.metric-editor .admin-hint { margin: 0; }
.memory-form fieldset legend { padding: 0 5px; font-size: 14px; font-weight: 600; }
.field-hint { color: var(--muted); font-size: 12px; }
.memory-form .primary-button { min-height: 44px; }
.account-memory-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 16px;
}
.account-memory-grid .admin-form { margin-top: 0; border: 0; padding-top: 0; }
.memory-history {
  border-radius: 9px;
  background: var(--surface-tint);
  border: 1px solid var(--line);
  padding: 12px;
}
.memory-history ol {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 365px;
  overflow-y: auto;
}
.memory-history li + li { border-top: 1px solid var(--line); padding-top: 9px; }
.memory-history li p {
  margin: 3px 0 9px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
@media (max-width: 1100px) {
  .account-memory-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 650px) {
  .admin-shell, .memory-fields { grid-template-columns: minmax(0, 1fr); }
  .admin-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-nav-label { display: none; }
  .admin-header h1 { font-size: 21px; }
}

.rule-library { margin-top: 18px; }
.rule-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.rule-toolbar label, .rule-extra label { display: grid; gap: 5px; min-width: 0; font-size: 14px; }
.rule-toolbar select {
  min-height: 44px;
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: inherit;
  background: #fff;
}
.rule-toolbar button, .rule-editor-header button { min-height: 44px; }
.rule-library-grid {
  display: grid;
  grid-template-columns: minmax(145px, .75fr) minmax(0, 2fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}
.rule-list {
  display: grid;
  gap: 6px;
  max-height: 480px;
  overflow-y: auto;
  min-width: 0;
}
.rule-list button, .rule-list p {
  text-align: left;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 8px;
  background: var(--surface-tint);
  overflow-wrap: anywhere;
  margin: 0;
}
.rule-list button[aria-pressed="true"] { background: var(--soft); color: var(--accent); }
.rule-list small, .rule-list p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.rule-editor { border-top: 0; margin-top: 0; padding-top: 0; }
.rule-editor-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.rule-key-hint { margin: -8px 0 0; line-height: 1.6; }
.rule-extra { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.rule-extra summary { cursor: pointer; font-size: 14px; }
.rule-extra > div { display: grid; gap: 10px; margin-top: 10px; }
@media (max-width: 1100px) {
  .rule-library-grid { grid-template-columns: minmax(0, 1fr); }
  .rule-list { max-height: 155px; }
}
@media (max-width: 650px) {
  .rule-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule-toolbar button { grid-column: 1 / -1; }
  .rule-toolbar select { font-size: 16px; }
}

.rule-toolbar:has(#company-rule-scope-field[hidden]) {
  grid-template-columns: minmax(0, 1fr) auto;
}
.skill-toolbar { margin-top: 16px; }
.skill-toolbar p { margin: 0 0 10px; }
.admin-skill-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 248px), 1fr));
  gap: 14px;
  margin-top: 18px;
}
.admin-skill-card {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-tint);
  text-align: left;
  align-content: start;
  overflow-wrap: anywhere;
}
.admin-skill-card:hover { border-color: #9cb9f2; background: var(--soft); }
.admin-skill-card strong { font-size: 16px; }
.admin-skill-card small, .catalog-card-description { color: var(--muted); line-height: 1.6; }
.admin-skill-card small { margin-top: 6px; }
.catalog-card-description { display: block; margin-top: 10px; }
.catalog-card-header { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.catalog-card-header .quick-icon { margin: 0 auto 0 0; }
.skill-source, .skill-version { padding: 3px 7px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.skill-source { background: var(--soft); color: var(--accent); }
.skill-version { background: #fff; color: var(--muted); border: 1px solid var(--line); }
.admin-skill-detail {
  width: min(560px, calc(100% - 24px));
  padding: clamp(16px, 3vw, 26px);
  border: 1px solid var(--line);
  border-radius: 13px;
  color: inherit;
}
.admin-skill-detail::backdrop { background: rgb(12 29 56 / 56%); }
.admin-skill-detail p, .admin-skill-detail dd { line-height: 1.6; }
.admin-skill-detail dl { display: grid; gap: 12px; }
.admin-skill-detail dt { font-size: 13px; font-weight: 700; color: var(--muted); }
.admin-skill-detail dd { margin: 4px 0 0; overflow-wrap: anywhere; }
.admin-skill-detail ul { margin: 0; padding-left: 1.2em; }
@media (max-width: 650px) {
  .rule-toolbar:has(#company-rule-scope-field[hidden]) { grid-template-columns: minmax(0, 1fr); }
  .skill-toolbar p { grid-column: 1 / -1; margin-bottom: 0; }
}

.entity-card > .quick-icon { margin-bottom: 10px; }
.company-branch { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.company-branch-title { display: flex; align-items: center; gap: 9px; }
.company-branch-title h3 { font-size: 17px; }
.company-branch .admin-skill-list {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 248px), 1fr));
  margin-top: 12px;
}
.entity-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.entity-detail-header h3 { margin-top: 5px; font-size: 19px; }
.entity-detail-header button { min-height: 44px; }
.entity-icon-preview { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

.draft-chat-link { display: block; margin-top: 8px; }
.personal-skills {
  width: min(1200px, calc(100% - 2 * var(--gutter)));
  margin: var(--gutter) auto;
  padding: clamp(14px, 3vw, 28px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.personal-skills h1 { margin: 4px 0; font-size: 24px; }
.personal-skills h3 { margin: 3px 0; }
.personal-skills .admin-hint { margin: 0; line-height: 1.6; }
#my-skills-status { margin-top: 12px; }
#main:has(:is(#my-skills, #all-skills, #merge-panel):not([hidden])) .scope { display: none; }
.all-skills-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.all-skills-toolbar input {
  width: min(100%, 320px);
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.address-prompt {
  display: grid;
  gap: 9px;
  margin: 10px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-tint);
}
.address-prompt-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.address-prompt-actions input {
  flex: 1 1 115px;
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.draft-editor-heading { margin-top: 18px; gap: 8px; }
.draft-stages { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.draft-stages button {
  min-height: 38px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 13px;
}
.draft-stages button[aria-current="step"] { background: var(--soft); color: var(--accent); font-weight: 700; }
.draft-section { border-top: 1px solid var(--line); margin-top: 15px; padding-top: 15px; }
.draft-section label { display: grid; gap: 6px; font-size: 14px; margin-top: 8px; }
.draft-files { display: grid; gap: 6px; padding: 0; list-style: none; }
.draft-files li { display: flex; align-items: center; justify-content: space-between; gap: 8px; overflow-wrap: anywhere; }
#draft-trial-result { background: var(--surface-tint); border-radius: 8px; padding: 10px; }
#draft-trial-result summary { cursor: pointer; font-weight: 600; }
#draft-trial-output, #draft-trial-report { white-space: pre-wrap; overflow-wrap: anywhere; }
