:root {
  --ink: oklch(0.19 0.025 250);
  --ink-strong: oklch(0.12 0.025 250);
  --muted: oklch(0.48 0.026 250);
  --faint: oklch(0.64 0.018 250);
  --paper: oklch(0.96 0.012 92);
  --surface: oklch(0.985 0.006 92);
  --surface-2: oklch(0.935 0.012 92);
  --line: oklch(0.84 0.016 92);
  --line-dark: oklch(0.72 0.024 92);
  --green: oklch(0.42 0.095 170);
  --green-soft: oklch(0.9 0.045 170);
  --red: oklch(0.46 0.13 32);
  --red-soft: oklch(0.91 0.05 32);
  --amber: oklch(0.68 0.125 75);
  --blue: oklch(0.43 0.08 245);
  --agent: oklch(0.99 0.004 92);
  --user: oklch(0.93 0.03 238);
  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --sans: "Avenir Next", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --shadow-low: 0 1px 0 rgba(20, 23, 28, 0.04), 0 12px 30px rgba(20, 23, 28, 0.07);
  --shadow-focus: 0 0 0 3px color-mix(in oklch, var(--green) 18%, transparent);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--sans);
  background:
    linear-gradient(to right, color-mix(in oklch, var(--line) 36%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in oklch, var(--line) 30%, transparent) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  text-rendering: optimizeLegibility;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: color-mix(in oklch, var(--paper) 84%, rgba(0, 0, 0, 0.18));
  backdrop-filter: blur(14px);
}

.auth-gate[hidden] {
  display: none;
}

.auth-panel {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow-low);
}

.auth-panel h2,
.auth-panel p {
  margin: 0;
}

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

.auth-locked .app-shell {
  pointer-events: none;
  filter: blur(2px);
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--green);
}

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

.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  transition: grid-template-columns 180ms ease;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: 18px minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.58)),
    var(--surface-2);
  padding: 18px 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  transition: transform 180ms ease, opacity 180ms ease;
  z-index: 2;
}

body.sidebar-collapsed .sidebar {
  transform: translateX(-238px);
  opacity: 0.94;
  pointer-events: none;
}

.sidebar-handle {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 30;
  width: 18px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line-dark);
  border-radius: 0;
  background: color-mix(in oklch, var(--ink-strong) 92%, transparent);
  opacity: 0;
  pointer-events: none;
}

body.sidebar-collapsed .sidebar-handle {
  opacity: 1;
  pointer-events: auto;
}

.brand {
  display: grid;
  gap: 14px;
  padding: 4px 0 18px;
  border-bottom: 1px solid var(--line-dark);
}

.brand-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--ink-strong);
  background: var(--ink-strong);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 800;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--red);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--ink-strong);
  letter-spacing: 0;
  text-wrap: balance;
}

h1 {
  font-size: 25px;
  line-height: 1.08;
}

.status-panel {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 88%, transparent);
  color: var(--muted);
  font-size: 13px;
}

.user-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

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

.admin-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface) 88%, transparent);
}

.admin-entry-copy {
  min-width: 0;
}

.admin-entry-copy strong,
.admin-entry-copy p {
  display: block;
  margin: 0;
}

.admin-entry-copy strong {
  color: var(--ink-strong);
  font-size: 13px;
}

.admin-entry-copy p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--green) 13%, transparent);
}

.primary-nav {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
}

.sidebar-section {
  display: grid;
  gap: 11px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.sidebar-section h2,
.chat-header h2 {
  font-size: 15px;
  line-height: 1.25;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.workspace-tabs,
.quick-actions,
.panel-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

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

.holdings-action-panel {
  padding: 14px;
}

.holdings-action-panel h2 {
  font-size: 14px;
}

.holdings-action-panel p,
.holdings-action-panel label {
  font-size: 12px;
}

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

.skill-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.chat-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.chat-upload-row .empty {
  margin: 0;
  font-size: 12px;
}

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

.chat-image-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-image-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in oklch, var(--surface-2) 60%, white);
  color: var(--ink);
  font-size: 12px;
}

.chat-image-chip button {
  min-height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
}

.agent-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.quick-prompt-chip {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in oklch, var(--surface) 82%, white);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.quick-prompt-chip:hover {
  border-color: var(--line-dark);
  background: color-mix(in oklch, var(--surface) 70%, var(--green-soft));
}

.mode,
.skill,
.skill-chip,
.intent-chip,
.workspace-tab,
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 760;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.mode:hover,
.skill:hover,
.skill-chip:hover,
.intent-chip:hover,
.workspace-tab:hover,
.icon-text:hover {
  border-color: var(--line-dark);
  background: color-mix(in oklch, var(--surface) 70%, var(--green-soft));
}

.mode.active,
.skill.active,
.skill-chip.active,
.intent-chip.active,
.workspace-tab.active {
  border-color: var(--ink-strong);
  background: var(--ink-strong);
  color: var(--paper);
}

.workspace-tab {
  display: grid;
  gap: 5px;
  min-height: 76px;
  padding: 12px;
  text-align: left;
  font-size: 13px;
}

.workspace-tab strong,
.workspace-tab span {
  display: block;
}

.workspace-tab strong {
  font-size: 14px;
  line-height: 1.25;
}

.workspace-tab span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 560;
  line-height: 1.45;
}

.workspace-tab.active span {
  color: color-mix(in oklch, var(--paper) 76%, transparent);
}

.workbench {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.workspace-panel {
  display: none;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: start;
}

.workspace-panel.active {
  display: grid;
}

.workspace-panel[data-workspace-panel="agent"].active {
  display: block;
}

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

.utility-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  border-left: 1px solid var(--line);
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.42)),
    var(--surface-2);
}

.tool-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface) 90%, transparent);
  box-shadow: 0 1px 0 rgba(20, 23, 28, 0.035);
}

.tool-section h2,
.view-header h2 {
  font-size: 16px;
  line-height: 1.25;
}

.view-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  gap: 18px;
  align-items: end;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 92%, transparent);
}

.view-header h2 {
  font-size: 24px;
}

.view-header p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.function-grid {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(380px, 1.1fr);
  gap: 16px;
  align-content: start;
  padding: 18px 20px 24px;
}

.function-grid .tool-section {
  margin-bottom: 0;
}

.holdings-list-section {
  grid-column: 1 / -1;
}

.holdings-summary {
  display: grid;
  gap: 10px;
}

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

.summary-grid div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface-2) 52%, white);
}

.summary-grid span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.summary-grid strong {
  color: var(--ink-strong);
  font-size: 17px;
}

.field-filter-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}

.field-filter-panel[hidden] {
  display: none;
}

.field-toggle {
  display: inline-flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 6px !important;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface-2) 52%, white);
}

.holdings-import-panel,
.holdings-entry-panel {
  grid-column: 1 / -1;
}

.holdings-import-panel[hidden],
.holdings-entry-panel[hidden] {
  display: none;
}

.import-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 10px;
  align-items: end;
}

.scanner-grid {
  grid-template-columns: minmax(360px, 0.82fr) minmax(360px, 1.18fr);
}

.method-note {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface-2) 66%, white);
}

.method-note strong {
  color: var(--ink-strong);
  font-size: 13px;
}

.method-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.intent {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 0;
  padding: 11px 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface) 86%, transparent);
  color: var(--ink);
}

.intent strong {
  color: var(--ink-strong);
  font-size: 13px;
  line-height: 1.35;
}

.intent span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 560;
  line-height: 1.55;
}

.intent:hover {
  border-color: var(--line-dark);
  background: var(--surface);
}

.intent.active {
  border-color: var(--ink-strong);
  background: var(--ink-strong);
}

.intent.active strong,
.intent.active span {
  color: var(--paper);
}

.skill {
  min-height: 36px;
  padding: 8px 10px;
}

.skill-chip,
.intent-chip {
  min-height: 34px;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 12px;
}

.holdings-panel,
.scan-panel {
  gap: 12px;
}

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

.holding-grid .full-row {
  grid-column: 1 / -1;
}

.import-box {
  display: grid;
  gap: 6px;
}

.import-box textarea,
#holdingNotes,
#scanRequirement {
  min-height: 76px;
}

.holdings-list {
  display: grid;
  gap: 9px;
  overflow-x: auto;
}

.holdings-table {
  min-width: max(980px, fit-content);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  overflow: hidden;
}

.holdings-row {
  display: grid;
  grid-template-columns: var(--holding-columns);
  min-height: 44px;
  border-top: 1px solid var(--line);
  align-items: center;
}

.holdings-row:first-child {
  border-top: 0;
}

.holdings-row > span {
  min-width: 0;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.holdings-row.holdings-group {
  background: color-mix(in oklch, var(--surface) 80%, white);
}

.holdings-row.holdings-lot {
  min-height: 40px;
  background: color-mix(in oklch, var(--surface-2) 60%, white);
}

.holdings-row.holdings-lot > span {
  font-size: 11px;
  color: var(--muted);
}

.holdings-head {
  min-height: 38px;
  background: color-mix(in oklch, var(--surface-2) 72%, white);
}

.holdings-head > span {
  justify-content: flex-start;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.holdings-row strong,
.holdings-row em {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.holdings-row strong {
  color: var(--ink-strong);
  font-size: 13px;
}

.holdings-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  margin-top: 2px;
}

.holding-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
}

.holding-checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--ink-strong);
}

.holding-code-stack {
  display: grid;
  gap: 3px;
  width: 100%;
}

.holding-code-main {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.holding-code-main strong {
  min-width: 64px;
}

.holding-code-stack-lot strong,
.holding-code-stack-lot em {
  padding-left: 30px;
}

.holding-toggle {
  min-width: 22px;
  min-height: 22px;
  padding: 0;
  border: 1px solid var(--line-dark);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.holding-toggle.is-hidden {
  visibility: hidden;
}

.holding-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.holding-lot-tag {
  color: var(--muted);
  font-size: 11px;
}

.row-action-select {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
}

.holding-detail-line {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
}

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

.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.detail-drawer[hidden] {
  display: none;
}

.detail-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 20, 24, 0.28);
  backdrop-filter: blur(2px);
}

.detail-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(560px, 100vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 18px;
  border-left: 1px solid var(--line-dark);
  background: var(--surface);
  box-shadow: var(--shadow-low);
}

.detail-drawer-body {
  overflow: auto;
  display: grid;
  gap: 12px;
}

.decision-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface) 86%, white);
}

.decision-card p,
.decision-card ul {
  margin: 0;
}

.admin-panel {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.admin-panel[hidden] {
  display: none;
}

.admin-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 20, 24, 0.34);
  backdrop-filter: blur(4px);
}

.admin-sheet {
  position: absolute;
  top: 0;
  right: 0;
  width: min(680px, 100vw);
  height: 100vh;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 20px;
  border-left: 1px solid var(--line-dark);
  background: var(--surface);
  box-shadow: var(--shadow-low);
}

.admin-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface) 92%, transparent);
}

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

.admin-section-head strong,
.admin-section-head p,
.admin-runtime-note span {
  display: block;
  margin: 0;
}

.admin-section-head strong {
  color: var(--ink-strong);
  font-size: 14px;
}

.admin-section-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.admin-runtime-note {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface-2) 62%, white);
}

.admin-runtime-note span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.decision-card ul {
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.decision-card strong {
  color: var(--ink-strong);
}

.decision-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.decision-meta span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: color-mix(in oklch, var(--surface-2) 56%, white);
  font-size: 11px;
}

.metric-ok {
  color: var(--green) !important;
  font-weight: 850;
}

.metric-risk {
  color: var(--red) !important;
  font-weight: 850;
}

.trade-plan-grid {
  grid-template-columns: minmax(360px, 0.75fr) minmax(420px, 1.25fr);
}

.trade-plan-actions,
.trade-plan-entry-panel {
  grid-column: 1 / -1;
}

.trade-plan-actions .panel-actions {
  grid-template-columns: minmax(160px, 240px);
}

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

.trade-plan-card {
  display: grid;
  gap: 7px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}

.trade-plan-card-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.trade-plan-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.trade-plan-fields span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface-2) 56%, white);
}

.trade-plan-card strong {
  color: var(--ink-strong);
}

.trade-plan-card p,
.trade-plan-card span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.intent.active,
.intent-chip.active,
.skill-chip.active {
  border-color: var(--ink-strong);
  background: var(--ink-strong);
  color: var(--paper);
}

.intent.active strong,
.intent.active span {
  color: var(--paper);
}

.secondary,
#sendBtn,
#runDecisionBtn,
#uploadFilesBtn,
.doc-actions button,
.alias-row button {
  width: auto;
  border-color: var(--ink-strong);
  background: var(--ink-strong);
  color: var(--paper);
}

.secondary {
  min-height: 38px;
  background: var(--red);
  border-color: var(--red);
}

.secondary:hover,
#sendBtn:hover,
#runDecisionBtn:hover,
#uploadFilesBtn:hover {
  transform: translateY(-1px);
}

.icon-text {
  width: auto;
  min-height: 32px;
  padding: 6px 10px;
  background: var(--surface);
  color: var(--ink);
}

.chat-main {
  min-width: 0;
  min-height: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.64), rgba(255, 255, 255, 0.2)),
    color-mix(in oklch, var(--paper) 84%, white);
}

.chat-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px) saturate(120%);
}

.chat-header h2 {
  font-size: 22px;
}

.active-context {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.active-context span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 28px 28px 22px;
}

.message {
  max-width: min(820px, 88%);
  margin-bottom: 16px;
  padding: 15px 17px 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--agent);
  box-shadow: var(--shadow-low);
  line-height: 1.72;
  white-space: normal;
  text-wrap: pretty;
}

.message span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.message p {
  margin: 0;
  white-space: pre-wrap;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.message-action-btn {
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.message-action-btn:hover {
  border-color: var(--line-dark);
  color: var(--ink);
}

.message.agent {
  border-left: 3px solid var(--green);
}

.message.user {
  margin-left: auto;
  border-color: color-mix(in oklch, var(--blue) 42%, var(--line));
  border-left: 1px solid color-mix(in oklch, var(--blue) 42%, var(--line));
  border-right: 3px solid var(--blue);
  background: var(--user);
}

.composer {
  border-top: 1px solid var(--line);
  padding: 14px 24px 18px;
  background: color-mix(in oklch, var(--surface) 94%, transparent);
  box-shadow: 0 -16px 34px rgba(26, 29, 34, 0.045);
}

.composer-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.composer-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

textarea {
  width: 100%;
  min-height: 102px;
  resize: vertical;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  padding: 13px;
  font: inherit;
  line-height: 1.62;
}

textarea::placeholder,
input::placeholder {
  color: color-mix(in oklch, var(--muted) 64%, transparent);
}

#sendBtn {
  min-height: 102px;
  font-size: 14px;
}

.decision-panel label,
.review-panel label,
.holdings-panel label,
.scan-panel label,
.document-card label,
.alias-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  font-weight: 520;
}

.toggle-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.toggle-row input {
  width: auto;
  min-height: auto;
  accent-color: var(--green);
}

.decision-output {
  min-height: 140px;
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface) 82%, var(--surface-2));
  color: var(--ink);
  white-space: pre-wrap;
  line-height: 1.58;
  font: 12px/1.58 var(--mono);
}

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

.upload-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px dashed color-mix(in oklch, var(--green) 65%, var(--line));
  border-radius: 4px;
  background: color-mix(in oklch, var(--green-soft) 52%, transparent);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.upload-box.dragging {
  border-color: var(--red);
  background: var(--red-soft);
  transform: translateY(-1px);
}

.file-picker {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 820;
}

.file-picker input {
  padding: 9px;
}

#uploadFilesBtn {
  min-width: 72px;
}

#uploadStatus {
  grid-column: 1 / -1;
  margin: 0;
}

.document-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(20, 23, 28, 0.04);
}

.doc-meta,
.doc-actions,
.entity-summary {
  grid-column: 1 / -1;
}

.doc-meta strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-strong);
  font-size: 13px;
}

.doc-meta span,
.empty {
  color: var(--muted);
  font-size: 13px;
}

.entity-summary {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in oklch, var(--surface-2) 70%, white);
  color: var(--muted);
  line-height: 1.55;
}

.entity-summary strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.entity-summary p {
  margin: 0;
}

.entity-empty {
  margin-top: 8px;
  color: var(--muted);
}

.alias-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.alias-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}

.alias-row strong,
.alias-row span {
  display: block;
}

.alias-row span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  margin-top: 2px;
}

.alias-row p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.alias-row button {
  min-width: 108px;
}

@media (max-width: 900px) {
  body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    display: grid;
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .primary-nav {
    grid-template-columns: 1fr;
  }

  .workspace-panel,
  .chat-main,
  .agent-layout {
    height: auto;
  }

  .agent-layout {
    grid-template-columns: 1fr;
  }

  .utility-panel {
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .view-header,
  .function-grid,
  .scanner-grid,
  .holding-grid {
    grid-template-columns: 1fr;
  }

  .chat-main {
    min-height: 720px;
  }

  .chat-header,
  .upload-box,
  .alias-row,
  .composer-box {
    grid-template-columns: 1fr;
  }

  .workspace-tabs,
  .quick-actions,
  .panel-actions,
  .holding-card-actions {
    grid-template-columns: 1fr;
  }

  .active-context {
    justify-content: start;
  }

  #sendBtn {
    width: 100%;
    min-height: 48px;
  }

  .message {
    max-width: 100%;
  }
}
