:root {
  --ink: #17211b;
  --muted: #627168;
  --paper: #f5f7f2;
  --surface: #ffffff;
  --line: #dce3dc;
  --green: #176b4d;
  --green-dark: #0d4f38;
  --green-soft: #e5f2eb;
  --amber: #d59a2e;
  --amber-soft: #fff5dc;
  --blue: #2e6584;
  --blue-soft: #e8f2f7;
  --violet: #6b598c;
  --violet-soft: #f1edf8;
  --danger: #a83d32;
  --danger-soft: #f9eae7;
  --shadow: 0 18px 48px rgba(23, 33, 27, 0.08);
  font-family:
    Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 86% 8%, rgba(23, 107, 77, 0.11), transparent 28rem),
    linear-gradient(180deg, #fbfcf9 0, var(--paper) 24rem);
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 64px 0 80px;
}

.hero {
  max-width: 850px;
  margin-bottom: 16px;
}

.eyebrow,
.result-kicker {
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-title {
  max-width: 760px;
  margin: 12px 0 14px;
  font-size: clamp(2.7rem, 6vw, 5.8rem);
  font-weight: 680;
  letter-spacing: -0.065em;
  line-height: 0.95;
}

.hero .eyebrow {
  margin: 0;
}

.integration-connect-card {
  margin: 0 0 22px;
  padding: 22px;
  border: 1px solid #cfe0d5;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 32px rgba(23, 33, 27, 0.06);
}

.integration-connect-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.integration-connect-card__header h2,
.integration-connect-card__header h3 {
  margin: 5px 0 0;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.integration-connect-badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 0.72rem;
  font-weight: 800;
}

.integration-connect-fields {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  margin-top: 18px;
}

.integration-connect-field label {
  margin-bottom: 7px;
  color: var(--muted);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.74rem;
}

.integration-connect-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.integration-connect-control--token {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.integration-connect-control input {
  height: 44px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.8rem;
}

.integration-connect-button {
  min-width: 104px;
  padding: 0 14px;
  border-radius: 11px;
  color: #fff;
  background: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
}

.integration-connect-button:hover:not(:disabled) {
  background: var(--green-dark);
}

.integration-connect-button--secondary {
  min-width: 82px;
  border: 1px solid #bfd1c5;
  color: var(--green-dark);
  background: #fff;
}

.integration-connect-button--secondary:hover:not(:disabled) {
  background: var(--green-soft);
}

.integration-connect-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.integration-connect-button:focus-visible {
  outline: 3px solid rgba(23, 107, 77, 0.24);
  outline-offset: 2px;
}

.integration-connect-status {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.integration-connect-status[data-state="success"] {
  color: var(--green);
}

.integration-connect-status[data-state="warning"] {
  color: #8a5f12;
}

.integration-connect-status[data-state="error"] {
  color: var(--danger);
}

.workspace-tabs {
  display: inline-flex;
  gap: 4px;
  margin: 0 0 22px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 24px rgba(23, 33, 27, 0.05);
}

.workspace-tabs button {
  padding: 10px 16px;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 800;
}

.workspace-tabs button[aria-selected="true"] {
  color: #fff;
  background: var(--green);
}

.settings-view {
  display: grid;
  gap: 20px;
}

.settings-view .integration-connect-card {
  margin: 0;
}

.settings-form {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.settings-form--compact {
  display: grid;
  gap: 18px;
}

.settings-section-heading h3 {
  margin: 4px 0 0;
  font-size: 1.18rem;
}

.settings-section-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.openai-billing-settings {
  display: flex;
  align-items: end;
  gap: 12px;
}

.openai-billing-settings label {
  display: grid;
  min-width: 220px;
  gap: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.openai-billing-settings select {
  min-height: 44px;
  padding: 0 38px 0 13px;
  border: 1px solid #cbd6ce;
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
}

.settings-switch {
  display: grid !important;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  min-width: min(100%, 330px) !important;
  gap: 10px !important;
  cursor: pointer;
}

.settings-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.settings-switch__control {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #b9c4bd;
  transition: background 150ms ease;
}

.settings-switch__control::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(24, 47, 37, 0.25);
  content: "";
  transition: transform 150ms ease;
}

.settings-switch input:checked + .settings-switch__control {
  background: var(--green);
}

.settings-switch input:checked + .settings-switch__control::after {
  transform: translateX(20px);
}

.settings-switch input:focus-visible + .settings-switch__control {
  outline: 3px solid rgba(15, 122, 83, 0.24);
  outline-offset: 2px;
}

.settings-switch__copy {
  display: grid;
  gap: 2px;
}

.settings-switch__copy strong {
  color: var(--ink);
  font-size: 0.82rem;
}

.settings-switch__copy small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
}

#save-openai-billing {
  min-height: 44px;
  padding: 0 17px;
  border-radius: 11px;
  color: #fff;
  background: var(--green);
  font-size: 0.82rem;
  font-weight: 800;
}

.settings-help {
  max-width: 850px;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 18px;
}

.settings-panel {
  display: grid;
  gap: 9px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfcfa;
}

.settings-panel label {
  font-size: 0.94rem;
  font-weight: 800;
}

.settings-panel textarea {
  width: 100%;
  min-height: 230px;
  resize: vertical;
  padding: 13px 14px;
  border: 1px solid #cbd6ce;
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.84rem;
  line-height: 1.55;
}

.settings-panel textarea:focus {
  border-color: var(--green);
  outline: 3px solid rgba(23, 107, 77, 0.13);
}

.settings-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}

#save-windows-files-ignore {
  padding: 11px 17px;
  border-radius: 11px;
  color: #fff;
  background: var(--green);
  font-size: 0.82rem;
  font-weight: 800;
}

#save-windows-files-ignore:hover:not(:disabled) {
  background: var(--green-dark);
}

#save-windows-files-ignore:disabled {
  cursor: wait;
  opacity: 0.6;
}

.settings-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.settings-status[data-state="success"] {
  color: var(--green);
}

.settings-status[data-state="error"] {
  color: var(--danger);
}

.snapshots-view {
  display: grid;
  gap: 18px;
}

.snapshots-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 170px auto;
  gap: 12px;
  align-items: end;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.snapshots-toolbar label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.snapshots-toolbar input,
.snapshots-toolbar select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.snapshots-layout {
  display: grid;
  grid-template-columns: minmax(310px, 0.9fr) minmax(420px, 1.4fr);
  gap: 18px;
  align-items: start;
}

.snapshots-list-panel,
.snapshot-detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.snapshots-list-panel {
  overflow: hidden;
}

.snapshots-list {
  display: grid;
  max-height: 720px;
  overflow: auto;
}

.snapshot-list-item {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 15px 17px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.snapshot-list-item:hover,
.snapshot-list-item[aria-pressed="true"] {
  background: var(--green-soft);
}

.snapshot-list-item__header {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
}

.snapshot-list-item__header strong,
.snapshot-list-item__object,
.snapshot-list-item small {
  overflow-wrap: anywhere;
}

.snapshot-list-item__object {
  color: var(--muted);
}

.snapshot-list-item small {
  color: var(--muted);
  line-height: 1.45;
}

.snapshot-list-item__time {
  font-size: 0.75rem;
}

.snapshots-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px;
}

.snapshots-pagination span {
  color: var(--muted);
  font-size: 0.82rem;
}

.snapshot-detail {
  min-height: 360px;
  padding: 20px;
}

.snapshot-detail__sections {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.snapshot-detail__sections section {
  padding: 14px 16px;
  border-radius: 13px;
  background: var(--paper);
}

.snapshot-detail__sections h4 {
  margin: 0 0 8px;
}

.snapshot-detail__sections ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.snapshot-knowledge-map {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}

.knowledge-map__heading,
.knowledge-fact__heading,
.knowledge-facts-toolbar,
.knowledge-details > summary {
  display: flex;
  align-items: center;
  gap: 10px;
}

.knowledge-map__heading {
  justify-content: space-between;
}

.knowledge-map__heading h4,
.knowledge-fact__heading h5 {
  margin: 0;
}

.knowledge-map__status,
.knowledge-fact__kind,
.knowledge-source,
.knowledge-details__count {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-size: 0.76rem;
  line-height: 1.25;
}

.knowledge-map__status {
  padding: 5px 9px;
  color: var(--muted);
  background: var(--surface);
}

.knowledge-map__status--completed {
  color: #17633b;
  background: #def7e8;
}

.knowledge-map__status--partial {
  color: #7a5000;
  background: #fff2c8;
}

.knowledge-map__status--failed {
  color: #922f2f;
  background: #ffe2e2;
}

.knowledge-map__warning,
.knowledge-map__summary,
.knowledge-map__empty,
.knowledge-map__meta {
  margin: 0;
}

.knowledge-map__warning {
  padding: 10px 12px;
  border-radius: 10px;
  color: #7a5000;
  background: #fff6d8;
}

.knowledge-map__summary {
  line-height: 1.55;
  white-space: pre-wrap;
}

.knowledge-map__empty,
.knowledge-map__meta {
  color: var(--muted);
}

.knowledge-map__meta {
  font-size: 0.8rem;
}

.knowledge-details {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.knowledge-details > summary {
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.knowledge-details > summary::-webkit-details-marker {
  display: none;
}

.knowledge-details > summary::after {
  content: "⌄";
  color: var(--muted);
  transition: transform 0.15s ease;
}

.knowledge-details[open] > summary::after {
  transform: rotate(180deg);
}

.knowledge-details__count {
  margin-left: auto;
  padding: 3px 8px;
  color: var(--muted);
  background: var(--paper);
}

.knowledge-details__body {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.knowledge-facts-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
}

.knowledge-facts-search {
  flex: 1 1 260px;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.knowledge-facts-status {
  color: var(--muted);
  font-size: 0.78rem;
}

.knowledge-facts,
.knowledge-conflicts {
  display: grid;
  gap: 9px;
}

.knowledge-fact,
.knowledge-conflict {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 11px;
  background: var(--paper);
}

.knowledge-conflict {
  border-left: 3px solid #d59a24;
}

.knowledge-conflict p,
.knowledge-fact__value {
  margin: 0;
  line-height: 1.45;
}

.knowledge-fact__heading {
  align-items: flex-start;
  flex-wrap: wrap;
}

.knowledge-fact__heading h5 {
  flex: 1 1 240px;
  font-size: 0.94rem;
}

.knowledge-fact__kind {
  padding: 4px 8px;
  color: var(--blue);
  background: rgba(53, 137, 230, 0.12);
}

.knowledge-sources {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.knowledge-sources__label {
  color: var(--muted);
  font-size: 0.76rem;
}

.knowledge-source {
  max-width: 100%;
  padding: 4px 8px;
  color: var(--muted);
  background: var(--surface);
  overflow-wrap: anywhere;
}

.knowledge-missing {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.knowledge-show-more {
  justify-self: start;
}

.snapshot-detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
}

@media (max-width: 850px) {
  .snapshots-toolbar,
  .snapshots-layout {
    grid-template-columns: 1fr;
  }

  .snapshots-list {
    max-height: 480px;
  }

  .snapshot-knowledge-map {
    padding: 12px;
  }

  .knowledge-map__heading,
  .knowledge-facts-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .knowledge-facts-search {
    flex-basis: auto;
    width: 100%;
  }

  .knowledge-sources {
    align-items: flex-start;
    flex-direction: column;
  }
}

.command-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.command-card {
  padding: 28px;
}

.section-heading,
.results-header,
.result-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.section-heading > div,
.results-header > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-heading h2,
.results-header h2,
.result-card h3 {
  margin: 0;
  letter-spacing: -0.025em;
}

.step-number {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-soft);
  font-size: 0.72rem;
  font-weight: 800;
}

.readonly-badge {
  padding: 7px 11px;
  border: 1px solid #b9d7c6;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 0.75rem;
  font-weight: 700;
}

form {
  margin-top: 28px;
}

label {
  display: block;
  margin-bottom: 9px;
  font-size: 0.85rem;
  font-weight: 700;
}

.command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input {
  min-width: 0;
  height: 54px;
  padding: 0 17px;
  border: 1px solid #cbd5ce;
  border-radius: 13px;
  outline: none;
  color: var(--ink);
  background: #fbfcfa;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

input:focus,
select:focus {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(23, 107, 77, 0.12);
}

input::placeholder {
  color: #93a098;
}

select {
  width: 100%;
  cursor: pointer;
}

select:disabled {
  cursor: wait;
  color: var(--muted);
}

.analysis-options {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: end;
  margin-top: 16px;
}

.analysis-options label {
  margin-bottom: 7px;
}

.analysis-options p {
  margin: 0 0 11px;
  color: var(--muted);
  font-size: 0.76rem;
}

button {
  border: 0;
  cursor: pointer;
}

#submit-button {
  display: flex;
  height: 54px;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 0 22px;
  border-radius: 13px;
  color: #fff;
  background: var(--green);
  font-weight: 750;
  transition:
    background 150ms ease,
    transform 150ms ease;
}

#submit-button:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

#submit-button:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
}

.input-hint {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.79rem;
}

.request-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  margin-top: 22px;
  padding: 10px 13px;
  border-radius: 11px;
  color: var(--muted);
  background: #f3f6f2;
  font-size: 0.84rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #93a098;
}

.request-status[data-state="loading"] .status-dot {
  background: var(--amber);
  animation: pulse 1s infinite alternate;
}

.request-status[data-state="success"] {
  color: var(--green-dark);
  background: var(--green-soft);
}

.request-status[data-state="success"] .status-dot {
  background: var(--green);
}

.request-status[data-state="error"] {
  color: var(--danger);
  background: #f9eae7;
}

.request-status[data-state="error"] .status-dot {
  background: var(--danger);
}

.results {
  margin-top: 48px;
}

[hidden] {
  display: none !important;
}

.deal-meta {
  max-width: 55%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deal-dashboard {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.deal-overview,
.ai-analysis-panel,
.timeline-panel,
.side-panel,
.deal-context-card,
.technical-data {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 34px rgba(23, 33, 27, 0.06);
}

.deal-overview {
  display: grid;
  grid-template-columns: minmax(260px, 1.15fr) minmax(480px, 1.85fr);
  gap: 34px;
  align-items: end;
  padding: 28px;
  border-color: #c6ddd0;
  border-radius: 24px;
}

.ai-analysis-panel {
  overflow: hidden;
  border-color: #c6d3ea;
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(235, 241, 255, 0.92), rgba(255, 255, 255, 0.98));
}

.ai-analysis-panel .panel-heading {
  border-bottom-color: #dce4f2;
}

.ai-analysis-panel .panel-count[data-state="completed"] {
  color: var(--green-dark);
  background: var(--green-soft);
}

.ai-analysis-panel .panel-count[data-state="pending"] {
  color: var(--blue);
  background: var(--blue-soft);
  animation: pulse 1s infinite alternate;
}

.ai-analysis-panel .panel-count[data-state="failed"] {
  color: var(--danger);
  background: #f9eae7;
}

.ai-analysis-body {
  padding: 22px 24px;
}

#ai-analysis-content {
  margin: 0;
  overflow-wrap: anywhere;
  color: #29362f;
  font-size: 0.9rem;
  line-height: 1.72;
}

.ai-markdown > :first-child {
  margin-top: 0;
}

.ai-markdown > :last-child {
  margin-bottom: 0;
}

.ai-markdown h2,
.ai-markdown h3,
.ai-markdown h4,
.ai-markdown h5,
.ai-markdown h6 {
  margin: 1.5em 0 0.55em;
  color: #17271e;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.ai-markdown h2 {
  font-size: 1.32rem;
}

.ai-markdown h3 {
  font-size: 1.16rem;
}

.ai-markdown h4,
.ai-markdown h5,
.ai-markdown h6 {
  font-size: 1rem;
}

.ai-markdown p {
  margin: 0.8em 0;
}

.ai-markdown ul,
.ai-markdown ol {
  display: grid;
  gap: 0.42em;
  margin: 0.8em 0;
  padding-left: 1.45rem;
}

.ai-markdown li {
  padding-left: 0.18rem;
}

.ai-markdown strong {
  color: #17271e;
  font-weight: 800;
}

.ai-markdown code {
  padding: 0.12em 0.38em;
  border-radius: 5px;
  color: #315e4b;
  background: rgba(23, 107, 77, 0.09);
  font: 0.86em/1.5 "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

.ai-markdown pre {
  height: auto;
  min-height: 0;
  max-height: 420px;
  margin: 1em 0;
  padding: 16px;
  border-radius: 12px;
  white-space: pre;
}

.ai-markdown pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

.ai-markdown blockquote {
  margin: 1em 0;
  padding: 10px 14px;
  border-left: 3px solid var(--green);
  color: #4e6257;
  background: rgba(229, 242, 235, 0.62);
}

.ai-markdown a {
  color: var(--green);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.ai-markdown hr {
  margin: 1.4em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.ai-markdown__table {
  margin: 1em 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.ai-markdown__table table {
  width: 100%;
  border-collapse: collapse;
}

.ai-markdown__table th,
.ai-markdown__table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.ai-markdown__table th {
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 0.75rem;
}

.ai-markdown__table tr:last-child td {
  border-bottom: 0;
}

.ai-analysis-meta {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.ai-analysis-progress {
  margin-top: 20px;
}

.ai-analysis-progress__track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce4f2;
}

.ai-analysis-progress__track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 500ms linear;
}

.ai-analysis-progress[data-state="completed"]
  .ai-analysis-progress__track
  span {
  background: var(--green);
}

.ai-analysis-progress[data-state="failed"] .ai-analysis-progress__track span {
  background: var(--danger);
}

.ai-analysis-progress p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.deal-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 13px;
}

.environment-badge,
.status-badge,
.panel-count,
.event-source {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
}

.environment-badge {
  padding: 6px 9px;
  color: var(--green-dark);
  background: var(--green-soft);
}

.status-badge {
  padding: 6px 9px;
  color: #77540d;
  background: var(--amber-soft);
}

.deal-overview h3 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  letter-spacing: -0.045em;
  line-height: 1.08;
}

.deal-overview__identity > p {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.deal-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--line);
}

.deal-metrics > div {
  min-width: 0;
  padding: 17px 16px;
  background: #fbfcfa;
}

.deal-metrics dt {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deal-metrics dd {
  margin: 7px 0 0;
  overflow: hidden;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 760;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deal-context-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.deal-context-card {
  min-width: 0;
  min-height: 118px;
  padding: 17px;
  border-radius: 16px;
}

.deal-context-card span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.deal-context-card strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.94rem;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.deal-context-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.deal-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.timeline-panel,
.side-panel {
  overflow: hidden;
  border-radius: 20px;
}

.panel-heading {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h3 {
  margin: 4px 0 0;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.panel-count {
  flex: 0 0 auto;
  padding: 6px 9px;
  color: var(--muted);
  background: #eef2ed;
}

.timeline-filters {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.timeline-filters button {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  background: #f1f4f0;
  font-size: 0.74rem;
  font-weight: 700;
}

.timeline-filters button:hover {
  color: var(--green-dark);
  background: var(--green-soft);
}

.timeline-filters button[aria-pressed="true"] {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.timeline-list {
  position: relative;
  display: grid;
  gap: 0;
  margin: 0;
  padding: 9px 20px 18px;
  list-style: none;
}

.timeline-list::before {
  position: absolute;
  top: 33px;
  bottom: 40px;
  left: 36px;
  width: 1px;
  background: var(--line);
  content: "";
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 13px 0;
}

.timeline-marker {
  z-index: 1;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 4px solid #fff;
  border-radius: 50%;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 0.68rem;
  font-weight: 850;
}

.timeline-item[data-category="communication"] .timeline-marker {
  color: var(--blue);
  background: var(--blue-soft);
}

.timeline-item[data-category="task"] .timeline-marker {
  color: #7b590e;
  background: var(--amber-soft);
}

.timeline-item[data-category="process"] .timeline-marker {
  color: var(--violet);
  background: var(--violet-soft);
}

.timeline-event {
  min-width: 0;
  padding: 2px 0 12px;
  border-bottom: 1px solid #edf0ec;
}

.timeline-event__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 0.72rem;
}

.event-source {
  padding: 4px 7px;
  color: var(--green-dark);
  background: var(--green-soft);
}

.timeline-event h4 {
  margin: 8px 0 0;
  font-size: 0.94rem;
  letter-spacing: -0.015em;
}

.timeline-event__summary {
  margin: 7px 0 0;
  overflow-wrap: anywhere;
  color: #435047;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-line;
}

.timeline-event__actor {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.panel-empty {
  margin: 0;
  padding: 28px 20px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.deal-sidebar {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 14px;
}

.side-list,
.quality-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.side-list-item,
.quality-item,
.side-empty {
  padding: 15px 18px;
  background: #fff;
}

.side-list-item h4 {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
}

.side-list-item p,
.side-list-item small {
  display: block;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.side-list-item__status {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 0.67rem;
  font-weight: 750;
}

.quality-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.quality-item::before {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--amber);
  content: "";
}

.quality-item[data-level="error"]::before {
  background: var(--danger);
}

.quality-item p {
  margin: 0;
  color: #4c554f;
  font-size: 0.76rem;
  line-height: 1.45;
}

.quality-ok {
  padding: 18px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.side-empty {
  color: var(--muted);
  font-size: 0.76rem;
}

.technical-data {
  margin-top: 20px;
  overflow: hidden;
  border-radius: 20px;
}

.technical-data > summary {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
}

.technical-data > summary::-webkit-details-marker {
  display: none;
}

.technical-data > summary strong {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
}

.technical-data__hint {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.technical-data[open] .technical-data__hint {
  color: var(--green-dark);
}

.technical-data .result-grid {
  margin-top: 0;
  padding: 0 18px 18px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.result-card {
  min-width: 0;
  overflow: hidden;
  box-shadow: 0 12px 34px rgba(23, 33, 27, 0.06);
}

.result-card--processed {
  border-color: #c6ddd0;
  display: flex;
  flex-direction: column;
}

.result-card > header {
  min-height: 78px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.result-card h3 {
  margin-top: 3px;
  font-size: 1.05rem;
}

.copy-button {
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: #eef2ed;
  font-size: 0.75rem;
  font-weight: 700;
}

.copy-button:hover {
  color: var(--green-dark);
  background: var(--green-soft);
}

pre {
  height: min(56vh, 650px);
  min-height: 420px;
  margin: 0;
  overflow: auto;
  padding: 22px;
  color: #d6e5db;
  background: #18231d;
  font: 0.79rem/1.65 "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  tab-size: 2;
  white-space: pre;
}

.result-card--processed > pre {
  height: auto;
  flex: 1;
  background: #122a20;
}

.raw-sections {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.raw-section {
  min-width: 0;
  background: var(--surface);
}

.raw-section > header {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: #fbfcfa;
}

.raw-section > header > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.raw-section h4 {
  margin: 0;
  overflow: hidden;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.raw-section-number {
  display: inline-grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 0.7rem;
  font-weight: 800;
}

.raw-section pre {
  height: 270px;
  min-height: 270px;
  border-top: 1px solid var(--line);
}

pre:focus {
  outline: 3px solid rgba(23, 107, 77, 0.35);
  outline-offset: -3px;
}

.error-log {
  margin-top: 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.error-log__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.error-log__header > div,
.error-log__header > div:first-child > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.error-log__header h2 {
  margin: 1px 0 0;
  font-size: 1.18rem;
}

.error-log__actions {
  flex: 0 0 auto;
}

#error-log-clear {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--green-dark);
  background: var(--surface);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 750;
  cursor: pointer;
}

#error-log-clear:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.55;
}

.error-log__empty {
  margin: 0;
  padding: 24px;
  color: var(--muted);
  font-size: 0.86rem;
}

.error-log__list {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  background: var(--line);
  list-style: none;
}

.error-log__item {
  padding: 18px 24px;
  background: #fff9f7;
}

.error-log__item header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.error-log__item header > div {
  display: grid;
  gap: 4px;
}

.error-log__item strong {
  color: #772e28;
  font-size: 0.88rem;
}

.error-log__item time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.72rem;
}

.error-log__source {
  color: #b3453b;
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.error-log__details {
  margin: 10px 0 0;
  color: var(--muted);
  font: 0.72rem/1.5 "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  overflow-wrap: anywhere;
}

.bi-view {
  display: grid;
  gap: 20px;
}

.bi-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.bi-header h2 {
  margin: 4px 0 8px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  letter-spacing: -0.055em;
}

.bi-header p {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.bi-controls {
  display: grid;
  grid-template-columns: minmax(130px, 170px) auto;
  align-items: end;
  gap: 8px;
  flex: 0 0 auto;
}

.bi-controls label {
  grid-column: 1 / -1;
  margin: 0;
}

.bi-controls select,
#bi-refresh {
  height: 44px;
  border: 1px solid #cbd5ce;
  border-radius: 11px;
}

.bi-controls select {
  padding-inline: 12px 34px;
  background: #fbfcfa;
}

#bi-refresh {
  padding: 0 16px;
  color: #fff;
  background: var(--green);
  font-weight: 750;
}

#bi-refresh:disabled {
  cursor: wait;
  opacity: 0.58;
}

.bi-status {
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--muted);
  background: #eef2ed;
  font-size: 0.82rem;
}

.bi-status[data-state="loading"] {
  color: #7a5c18;
  background: var(--amber-soft);
}

.bi-status[data-state="success"] {
  color: var(--green-dark);
  background: var(--green-soft);
}

.bi-status[data-state="error"] {
  color: var(--danger);
  background: var(--danger-soft);
}

.bi-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.bi-metrics article {
  display: grid;
  min-height: 145px;
  align-content: space-between;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 26px rgba(23, 33, 27, 0.05);
}

.bi-metrics span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bi-metrics strong {
  font-size: clamp(1.7rem, 3.5vw, 2.75rem);
  letter-spacing: -0.05em;
}

.bi-metrics small {
  color: var(--muted);
  font-size: 0.75rem;
}

.bi-metrics .bi-metric--cost {
  border-color: #285f4b;
  color: #f1f8f4;
  background: #143f31;
}

.bi-metric--cost span,
.bi-metric--cost small {
  color: #bdd7ca;
}

.bi-rate-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 20px;
  border: 1px solid #d8c992;
  border-radius: 15px;
  background: #fffae9;
}

.bi-rate-note > div {
  display: grid;
  gap: 3px;
}

.bi-rate-note span {
  color: #8a6b20;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bi-rate-note p {
  max-width: 660px;
  margin: 0;
  color: #6c6041;
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: right;
}

.bi-grid {
  display: grid;
  gap: 20px;
}

.bi-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.bi-panel > header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.bi-panel h3 {
  margin: 3px 0 0;
  font-size: 1.15rem;
}

.bi-daily-chart {
  display: grid;
  max-height: 470px;
  gap: 10px;
  overflow: auto;
  padding: 20px 22px;
}

.bi-daily-row {
  display: grid;
  grid-template-columns: 70px minmax(120px, 1fr) 135px 90px;
  align-items: center;
  gap: 12px;
  min-width: 560px;
}

.bi-daily-row time,
.bi-daily-row small {
  color: var(--muted);
  font-size: 0.72rem;
}

.bi-daily-row strong {
  font-size: 0.76rem;
  text-align: right;
}

.bi-daily-row small {
  text-align: right;
}

.bi-daily-row__track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eee9;
}

.bi-daily-row__track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #5d9b7f);
}

.bi-table-wrap {
  overflow-x: auto;
}

.bi-table {
  width: 100%;
  min-width: 1260px;
  border-collapse: collapse;
}

.bi-table th,
.bi-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.bi-table th:first-child,
.bi-table td:first-child {
  text-align: left;
}

.bi-table th {
  color: var(--muted);
  background: #f7f9f6;
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.bi-table td {
  font-size: 0.8rem;
}

.bi-table td:first-child,
.bi-table td:nth-child(2) {
  display: table-cell;
}

.bi-table td strong,
.bi-table td small {
  display: block;
}

.bi-table td small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
}

.history-view {
  display: grid;
  gap: 20px;
}

.free-quota-card {
  display: grid;
  gap: 22px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.free-quota-card__header,
.free-quota-bar__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.free-quota-card__header h3 {
  margin: 4px 0 0;
  font-size: 1.2rem;
}

.free-quota-bars {
  display: grid;
  gap: 24px;
}

.free-quota-bar {
  display: grid;
  gap: 10px;
}

.free-quota-bar__heading strong {
  font-size: 0.92rem;
}

.free-quota-bar__heading small {
  color: var(--muted);
  font-size: 0.72rem;
}

.free-quota-bar__value {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  letter-spacing: -0.04em;
}

.free-quota-bar__track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eae7;
}

.free-quota-bar__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #16a34a;
  transition: width 300ms ease;
}

.free-quota-bar[data-state="warning"] .free-quota-bar__fill {
  background: var(--amber);
}

.free-quota-bar[data-state="danger"] .free-quota-bar__fill {
  background: var(--danger);
}

.free-quota-bar[data-state="empty"] .free-quota-bar__fill {
  background: #cbd1cc;
}

.free-quota-bar__note,
.free-quota-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.free-quota-bar__overage {
  color: var(--danger);
  font-weight: 750;
}

.free-quota-meta {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.history-refresh {
  height: 44px;
  padding: 0 18px;
  border-radius: 11px;
  color: #fff;
  background: var(--green);
  font-weight: 750;
}

.history-refresh:disabled {
  cursor: wait;
  opacity: 0.58;
}

.history-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1.5fr);
  gap: 18px;
  align-items: start;
}

.history-list-panel,
.history-detail {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.history-list-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
}

.history-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.history-list-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 16px 18px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  transition:
    background 150ms ease,
    box-shadow 150ms ease;
}

.history-list-item:hover {
  background: #f7faf7;
}

.history-list-item[aria-pressed="true"] {
  position: relative;
  z-index: 1;
  background: var(--green-soft);
  box-shadow: inset 3px 0 var(--green);
}

.history-list-item__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-list-item__top strong {
  font-size: 0.78rem;
}

.history-list-item__deal {
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-list-item small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-status {
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: #eef2ed;
  font-size: 0.62rem;
  font-weight: 800;
}

.history-status--completed {
  color: var(--green-dark);
  background: #d9eee2;
}

.history-status--failed {
  color: var(--danger);
  background: var(--danger-soft);
}

.history-status--running {
  color: #856118;
  background: var(--amber-soft);
}

.history-detail {
  min-height: 420px;
}

.history-detail__empty {
  margin: 0;
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
}

.history-detail__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.history-detail__header h3 {
  margin: 4px 0 0;
  font-size: 1.25rem;
}

.history-detail__header .panel-count[data-state="completed"] {
  color: var(--green-dark);
  background: var(--green-soft);
}

.history-detail__header .panel-count[data-state="failed"] {
  color: var(--danger);
  background: var(--danger-soft);
}

.history-detail__header .panel-count[data-state="running"] {
  color: #856118;
  background: var(--amber-soft);
}

.history-detail__header .panel-count[data-state="queued"] {
  color: #856118;
  background: var(--amber-soft);
}

.history-status--queued {
  color: #856118;
  background: var(--amber-soft);
}

.operation-progress {
  display: grid;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}

.operation-progress__track {
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1e8e3;
}

.operation-progress__track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 500ms linear;
}

.operation-progress[data-state="queued"] .operation-progress__track span {
  width: 4% !important;
  background: #c2942e;
}

.operation-progress__label {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.snapshot-list-item[data-state="queued"],
.snapshot-list-item[data-state="running"] {
  border-left: 3px solid #c2942e;
  background: #fffdf6;
}

.snapshot-progress-section p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.history-detail__metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.history-detail__metrics > div {
  display: grid;
  gap: 5px;
  padding: 13px 16px;
  background: #f8faf7;
}

.history-detail__metrics span {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.history-detail__metrics strong {
  font-size: 0.82rem;
}

.history-detail__link {
  display: inline-block;
  margin: 18px 24px 0;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
}

.history-analysis-content {
  padding: 22px 24px 28px;
  color: #29362f;
  font-size: 0.9rem;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-view {
  --telegram-blue: #3390ec;
  --telegram-blue-dark: #247bc2;
  --telegram-wallpaper: #e7edf0;
  --telegram-own: #d9fdd3;
  width: min(100%, 1040px);
  margin: 0 auto;
}

.telegram-chat {
  display: flex;
  min-height: 640px;
  height: min(780px, calc(100vh - 190px));
  overflow: hidden;
  border: 1px solid #cfd9df;
  border-radius: 18px;
  background: var(--telegram-wallpaper);
  box-shadow: 0 20px 56px rgba(41, 73, 92, 0.16);
}

.telegram-chat {
  flex-direction: column;
}

.telegram-chat__header {
  z-index: 4;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid #d8e0e5;
  background: rgba(255, 255, 255, 0.98);
}

.telegram-chat__identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.telegram-avatar,
.chat-empty__icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #54a9eb, var(--telegram-blue-dark));
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(51, 144, 236, 0.25);
}

.telegram-avatar {
  width: 46px;
  height: 46px;
  font-size: 0.78rem;
}

.telegram-chat__header h2 {
  overflow: hidden;
  margin: 0;
  font-size: 1rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.telegram-chat__header p {
  margin: 4px 0 0;
  color: #71828d;
  font-size: 0.72rem;
}

.telegram-chat__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.telegram-chat__refresh {
  flex: 0 0 auto;
  padding: 9px 13px;
  border-radius: 9px;
  color: var(--telegram-blue-dark);
  background: #edf6fd;
  font-size: 0.75rem;
  font-weight: 800;
  transition:
    background 150ms ease,
    opacity 150ms ease;
}

.telegram-chat__refresh:hover:not(:disabled) {
  background: #dceefe;
}

.telegram-chat__analysis {
  color: #fff;
  background: var(--telegram-blue);
}

.telegram-chat__analysis:hover:not(:disabled) {
  background: var(--telegram-blue-dark);
}

.telegram-chat__refresh:disabled {
  cursor: wait;
  opacity: 0.5;
}

.chat-pinned-analysis {
  display: flex;
  width: 100%;
  min-height: 54px;
  z-index: 3;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-bottom: 1px solid #d4dfe5;
  border-radius: 0;
  color: #273b48;
  background: rgba(255, 255, 255, 0.96);
  text-align: left;
}

.chat-pinned-analysis:hover {
  background: #f6fbff;
}

.chat-pinned-analysis__icon {
  flex: 0 0 auto;
}

.chat-pinned-analysis__copy {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 2px;
}

.chat-pinned-analysis strong {
  font-size: 0.78rem;
}

.chat-pinned-analysis small {
  overflow: hidden;
  color: #71828d;
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-pinned-analysis__action {
  color: var(--telegram-blue);
  font-size: 0.7rem;
  font-weight: 750;
}

.chat-pinned-analysis:focus-visible {
  outline: 3px solid rgba(51, 144, 236, 0.32);
  outline-offset: -3px;
}

.chat-pinned-analysis[aria-busy="true"] {
  cursor: wait;
  opacity: 0.72;
}

.chat-empty,
.chat-conversation {
  background:
    radial-gradient(circle at 20px 20px, rgba(93, 124, 142, 0.07) 1px, transparent 1px),
    radial-gradient(circle at 52px 52px, rgba(93, 124, 142, 0.05) 1px, transparent 1px),
    var(--telegram-wallpaper);
  background-size:
    64px 64px,
    64px 64px,
    auto;
}

.chat-empty {
  display: grid;
  flex: 1;
  place-content: center;
  justify-items: center;
  padding: 48px 22px;
  text-align: center;
}

.chat-empty__icon {
  width: 74px;
  height: 74px;
  margin-bottom: 18px;
  font-size: 1rem;
}

.chat-empty h3 {
  margin: 0;
  color: #273b48;
  font-size: 1.1rem;
}

.chat-empty p {
  max-width: 430px;
  margin: 10px 0 20px;
  color: #687b87;
  font-size: 0.82rem;
  line-height: 1.55;
}

.chat-empty button {
  padding: 10px 16px;
  border-radius: 10px;
  color: #fff;
  background: var(--telegram-blue);
  font-size: 0.78rem;
  font-weight: 800;
}

.chat-conversation {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-load-earlier {
  display: block;
  margin: 14px auto 4px;
  padding: 7px 12px;
  border-radius: 999px;
  color: #4f6877;
  background: rgba(255, 255, 255, 0.88);
  font-size: 0.68rem;
  font-weight: 750;
  box-shadow: 0 2px 8px rgba(51, 75, 89, 0.1);
}

.chat-messages {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: flex-end;
  gap: 5px;
  padding: 18px clamp(14px, 4vw, 52px) 22px;
}

.chat-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-radius: 14px;
  outline: none;
  transition:
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.chat-message--own {
  justify-content: flex-end;
}

.chat-message--system {
  justify-content: center;
  margin: 7px 0;
}

.chat-message__avatar {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--telegram-blue);
  font-size: 0.56rem;
  font-weight: 850;
}

.chat-message__body {
  max-width: 72%;
}

.chat-message__author {
  margin: 0 10px 3px;
  color: #4b7190;
  font-size: 0.64rem;
  font-weight: 800;
}

.chat-message--own .chat-message__author {
  text-align: right;
}

.chat-bubble {
  position: relative;
  min-width: 88px;
  padding: 8px 10px 6px;
  border-radius: 12px 12px 12px 4px;
  color: #172b36;
  background: #fff;
  box-shadow: 0 1px 2px rgba(36, 57, 69, 0.14);
}

.chat-message--own .chat-bubble {
  border-radius: 12px 12px 4px;
  background: var(--telegram-own);
}

.chat-message--failed .chat-bubble {
  border: 1px solid #e6aaa4;
  background: #fff4f2;
}

.chat-message--full-analysis .chat-bubble {
  border-left: 3px solid var(--telegram-blue);
}

.chat-message--highlighted {
  background: rgba(51, 144, 236, 0.12);
  box-shadow: 0 0 0 8px rgba(51, 144, 236, 0.12);
}

.chat-analysis-label {
  display: inline-flex;
  margin-bottom: 7px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #1769aa;
  background: #e8f4ff;
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.chat-analysis-meta {
  margin: 7px 0 0;
  color: #70848f;
  font-size: 0.62rem;
}

.chat-message--system .chat-bubble {
  max-width: min(86%, 560px);
  min-width: 0;
  padding: 5px 10px;
  border-radius: 999px;
  color: #fff;
  background: rgba(91, 119, 134, 0.74);
  font-size: 0.65rem;
  text-align: center;
  box-shadow: none;
}

.chat-bubble__content {
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  line-height: 1.48;
}

.chat-bubble__content > :first-child {
  margin-top: 0;
}

.chat-bubble__content > :last-child {
  margin-bottom: 0;
}

.chat-bubble__content p {
  margin: 0 0 7px;
}

.chat-bubble__content ul,
.chat-bubble__content ol {
  display: grid;
  gap: 6px;
  margin: 8px 0;
  padding-left: 22px;
}

.chat-bubble__content li { padding-left: 2px; }

.chat-bubble__content .chat-citation {
  display: inline-block;
  padding: 0 4px;
  border-radius: 5px;
  background: #e8f2ed;
  color: #176b4d;
  font-size: 0.88em;
  font-weight: 750;
  text-decoration: none;
}

.chat-bubble__content h1,
.chat-bubble__content h2,
.chat-bubble__content h3,
.chat-bubble__content h4 {
  margin: 10px 0 5px;
  font-size: 0.84rem;
}

.chat-bubble__meta {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 5px;
  margin: 4px 0 0 10px;
  color: #76909d;
  font-size: 0.58rem;
  line-height: 1;
  white-space: nowrap;
}

.chat-bubble__details {
  margin-top: 7px;
}

.chat-bubble__details > summary {
  width: max-content;
  padding: 3px 8px;
  border: 1px solid #d7dde1;
  border-radius: 999px;
  color: #536d7c;
  background: rgb(255 255 255 / 72%);
  font-size: 0.62rem;
  font-weight: 750;
  line-height: 1.2;
  cursor: pointer;
  list-style: none;
}

.chat-bubble__details > summary::-webkit-details-marker { display: none; }

.chat-bubble__details[open] > summary { margin-bottom: 7px; }

.chat-bubble__details .chat-bubble__meta {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-left: 0;
  line-height: 1.35;
  white-space: normal;
}

.chat-message__model,
.chat-message__cost {
  font-weight: 750;
}

.verification-warning {
  margin: 10px 0 0 !important;
  padding: 8px 10px;
  border: 1px solid #efc56e;
  border-radius: 8px;
  color: #6f4b08;
  background: #fff7df;
  font-size: 0.72rem;
  line-height: 1.35;
}

.verification-warning--unavailable {
  border-color: #b8c9d5;
  color: #415967;
  background: #f2f7fa;
}

.chat-feedback {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.chat-feedback__button {
  min-width: 28px;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font-size: 0.72rem;
}

.chat-feedback__button:hover,
.chat-feedback__button[aria-pressed="true"] {
  border-color: #bcd9f2;
  background: #e8f4ff;
}

.chat-message--own .chat-bubble__meta {
  color: #5f8b73;
}

.chat-message__retry {
  margin-top: 7px;
  padding: 0;
  color: #b14c42;
  background: transparent;
  font-size: 0.64rem;
  font-weight: 800;
}

.chat-typing {
  display: inline-flex;
  height: 18px;
  align-items: center;
  gap: 4px;
  padding: 0 3px;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8297a2;
  animation: telegram-typing 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.16s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.32s;
}

.chat-quick-prompts {
  display: flex;
  gap: 8px;
  padding: 9px 14px;
  overflow-x: auto;
  border-top: 1px solid #d8e0e5;
  background: #f7fafc;
}

.chat-quick-prompts button {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid #bcd9f2;
  border-radius: 999px;
  color: var(--telegram-blue-dark);
  background: #fff;
  font-size: 0.68rem;
  font-weight: 750;
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 9px;
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid #d8e0e5;
  background: #fff;
}

.chat-composer__field {
  position: relative;
  min-width: 0;
}

.chat-composer textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 128px;
  resize: none;
  padding: 11px 72px 10px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  outline: none;
  color: #20323d;
  background: #f2f5f7;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.4;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.chat-composer textarea:focus {
  border-color: var(--telegram-blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(51, 144, 236, 0.13);
}

.chat-composer textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.chat-character-count {
  position: absolute;
  right: 12px;
  bottom: 10px;
  color: #8a9aa3;
  font-size: 0.58rem;
  pointer-events: none;
}

.chat-send {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  align-self: end;
  border-radius: 50%;
  color: #fff;
  background: var(--telegram-blue);
  font-size: 1rem;
  box-shadow: 0 5px 14px rgba(51, 144, 236, 0.24);
  transition:
    transform 150ms ease,
    opacity 150ms ease;
}

.chat-send:hover:not(:disabled) {
  transform: translateY(-1px);
}

.chat-send:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  box-shadow: none;
}

.chat-status {
  min-height: 24px;
  margin: 0;
  padding: 5px 16px 7px;
  color: #71828d;
  background: #fff;
  font-size: 0.62rem;
}

.chat-status[data-state="error"] {
  color: var(--danger);
}

@keyframes telegram-typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes pulse {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100% - 28px, 720px);
    padding-top: 38px;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .deal-overview,
  .deal-workspace,
  .bi-metrics,
  .history-layout {
    grid-template-columns: 1fr;
  }

  .bi-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-list-panel {
    position: static;
    max-height: 360px;
  }

  .integration-connect-fields {
    grid-template-columns: 1fr;
  }

  .deal-context-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .deal-sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-panel--quality {
    grid-column: 1 / -1;
  }

  pre {
    height: 500px;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 20px, 540px);
    padding-bottom: 40px;
  }

  .command-card {
    padding: 20px;
    border-radius: 18px;
  }

  .workspace-tabs {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
  }

  .workspace-tabs button {
    flex: 0 0 auto;
  }

  .integration-connect-card {
    padding: 18px;
    border-radius: 16px;
  }

  .integration-connect-card__header {
    display: grid;
  }

  .integration-connect-badge {
    justify-self: start;
  }

  .integration-connect-control,
  .integration-connect-control--token {
    grid-template-columns: 1fr 1fr;
  }

  .integration-connect-control input {
    grid-column: 1 / -1;
  }

  .openai-billing-settings,
  .free-quota-card__header,
  .free-quota-bar__heading {
    display: grid;
  }

  .openai-billing-settings label {
    min-width: 0;
  }

  .bi-header,
  .bi-rate-note {
    display: grid;
  }

  .bi-controls {
    width: 100%;
  }

  .bi-rate-note p {
    text-align: left;
  }

  .bi-metrics {
    grid-template-columns: 1fr;
  }

  .history-detail__metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .command-row {
    grid-template-columns: 1fr;
  }

  .analysis-options {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .telegram-chat {
    min-height: 600px;
    height: calc(100vh - 120px);
    border-radius: 12px;
  }

  .telegram-chat__header {
    min-height: 62px;
    padding: 8px 12px;
  }

  .telegram-avatar {
    width: 42px;
    height: 42px;
  }

  .telegram-chat__refresh {
    max-width: 92px;
    padding: 8px 9px;
    line-height: 1.15;
  }

  .telegram-chat__actions {
    gap: 5px;
  }

  .chat-pinned-analysis__content {
    padding: 2px 18px 16px;
  }

  .chat-messages {
    padding-right: 10px;
    padding-left: 10px;
  }

  .chat-message__body {
    max-width: 88%;
  }

  .chat-quick-prompts {
    padding-right: 10px;
    padding-left: 10px;
  }

  .chat-composer {
    padding-right: 10px;
    padding-left: 10px;
  }

  #submit-button {
    width: 100%;
  }

  .readonly-badge,
  .deal-meta {
    display: none;
  }

  .deal-overview {
    gap: 22px;
    padding: 20px;
    border-radius: 18px;
  }

  .deal-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .deal-context-cards,
  .deal-sidebar {
    grid-template-columns: 1fr;
  }

  .side-panel--quality {
    grid-column: auto;
  }

  .timeline-panel,
  .side-panel,
  .technical-data,
  .error-log {
    border-radius: 16px;
  }

  .error-log__header,
  .error-log__item {
    padding-inline: 16px;
  }

  .error-log__item header {
    display: grid;
    gap: 8px;
  }

  .timeline-filters {
    padding-inline: 15px;
  }

  .timeline-list {
    padding-inline: 15px;
  }

  .timeline-list::before {
    left: 31px;
  }

  .technical-data .result-grid {
    padding: 0 10px 10px;
  }

  .results {
    margin-top: 34px;
  }

  pre {
    min-height: 360px;
    padding: 16px;
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* OpenAI Platform-inspired application shell and component system */
:root {
  --ink: #0d0d0d;
  --muted: #6b6b6b;
  --paper: #ffffff;
  --surface: #ffffff;
  --surface-subtle: #f7f7f8;
  --surface-hover: #f2f2f2;
  --line: #e5e5e5;
  --line-strong: #d4d4d4;
  --green: #0f7a55;
  --green-dark: #096542;
  --green-soft: #eaf6f0;
  --amber: #b7791f;
  --amber-soft: #fff7df;
  --blue: #3b6b8c;
  --blue-soft: #edf5f9;
  --violet: #6d5b8e;
  --violet-soft: #f4f0fa;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: none;
  --shadow-soft: none;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html {
  min-height: 100%;
  background: var(--surface);
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.sidebar-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  color: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid rgba(15, 122, 85, 0.38);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  display: flex;
  width: 240px;
  min-height: 100vh;
  flex-direction: column;
  padding: 14px 12px 12px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface-subtle);
}

.sidebar-brand {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 11px;
  padding: 5px 8px;
}

.sidebar-brand__mark {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: #111;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand strong {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.sidebar-brand div > span {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

.sidebar-environment {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  margin: 8px 3px 17px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #4e4e4e;
  background: var(--surface);
  font-size: 11px;
  font-weight: 550;
}

.sidebar-environment__dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.server-version {
  margin-left: auto;
  color: #a9bbb1;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.67rem;
  white-space: nowrap;
}

.workspace-tabs {
  display: grid;
  width: 100%;
  gap: 2px;
  margin: 0 0 18px;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.workspace-tabs--system {
  margin: auto 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.sidebar-group-label {
  padding: 0 9px 7px;
  color: #8a8a8a;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.workspace-tabs button {
  display: flex;
  width: 100%;
  min-height: 38px;
  flex: none;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  color: #404040;
  background: transparent;
  font-size: 13px;
  font-weight: 520;
  text-align: left;
}

.workspace-tabs button:hover {
  color: var(--ink);
  background: #ededed;
}

.workspace-tabs button[aria-selected="true"] {
  color: var(--ink);
  background: #e7e7e7;
  font-weight: 620;
}

.workspace-tabs button svg,
.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-main {
  min-width: 0;
  min-height: 100vh;
  margin-left: 240px;
  background: var(--surface);
}

.mobile-topbar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.page-topbar {
  display: flex;
  min-height: 112px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.page-topbar > div {
  min-width: 0;
}

.page-topbar__eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}

.page-topbar h1 {
  margin: 0;
  font-size: clamp(22px, 2vw, 28px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.page-topbar h1 + p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.page-topbar .readonly-badge {
  margin-top: 5px;
}

.page-shell {
  width: min(1180px, calc(100% - 64px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.page-shell:focus {
  outline: 0;
}

.hero {
  display: none;
}

[data-workspace-view] {
  min-width: 0;
}

.readonly-badge,
.environment-badge,
.status-badge,
.panel-count,
.integration-connect-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #4d4d4d;
  background: var(--surface-subtle);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.step-number {
  display: none;
}

.command-card,
.results,
.error-log,
.settings-form,
.integration-connect-card,
.bi-panel,
.free-quota-card,
.history-list-panel,
.history-detail,
.snapshots-list-panel,
.snapshot-detail,
.deal-overview,
.timeline-panel,
.side-panel,
.technical-data,
.result-card,
.ai-analysis-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: none;
}

.command-card,
.settings-form,
.integration-connect-card {
  padding: 20px;
}

.section-heading,
.results-header,
.bi-header {
  min-height: 0;
  align-items: flex-start;
}

.section-heading h2,
.results-header h2,
.bi-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 620;
  letter-spacing: -0.015em;
}

.section-heading,
.results-header {
  margin-bottom: 18px;
}

.command-row {
  gap: 8px;
}

input,
select,
textarea,
.integration-connect-control input {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #8e8e8e;
  outline: 0;
  box-shadow: 0 0 0 2px rgba(13, 13, 13, 0.08);
}

label {
  color: #454545;
  font-size: 12px;
  font-weight: 550;
}

button,
#submit-button,
.history-refresh,
.integration-connect-button,
.settings-actions button,
.snapshots-toolbar button,
.snapshot-detail__actions button,
.bi-controls button {
  border-radius: 8px;
  box-shadow: none;
}

#submit-button,
.integration-connect-button,
.settings-actions button,
.chat-send {
  color: #fff;
  background: #111;
}

#submit-button:hover:not(:disabled),
.integration-connect-button:hover:not(:disabled),
.settings-actions button:hover:not(:disabled),
.chat-send:hover:not(:disabled) {
  background: #2b2b2b;
}

.integration-connect-button--secondary {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--surface);
}

.integration-connect-button--secondary:hover:not(:disabled) {
  border-color: #b7b7b7;
  background: var(--surface-hover);
}

.request-status {
  border-radius: 8px;
  background: var(--surface-subtle);
}

.results {
  margin-top: 20px;
  padding: 20px;
}

.result-grid {
  gap: 12px;
}

.result-card {
  overflow: hidden;
}

.deal-overview {
  padding: 20px;
}

.deal-metrics > div {
  border-color: var(--line);
  background: var(--surface-subtle);
}

.deal-overview h3,
.panel-heading h3,
.side-panel h3 {
  color: var(--ink);
}

.ai-analysis-panel {
  border-color: var(--line);
  background: var(--surface);
}

.ai-analysis-panel::before {
  background: var(--green);
}

.timeline-filters button[aria-pressed="true"] {
  border-color: #cfcfcf;
  color: var(--ink);
  background: var(--surface-hover);
}

.technical-data {
  margin-top: 12px;
}

pre {
  border-radius: 8px;
  color: #d6d6d6;
  background: #171717;
}

.error-log {
  margin-top: 20px;
}

.bi-view,
.history-view,
.snapshots-view,
.settings-view {
  gap: 16px;
}

.bi-header {
  margin-bottom: 16px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.bi-controls {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(110px, 140px) auto;
  align-items: end;
  gap: 8px;
}

.bi-controls label,
.snapshots-toolbar label {
  color: var(--muted);
}

.bi-controls label {
  display: grid;
  grid-column: auto;
  gap: 6px;
  margin: 0;
}

.bi-controls label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}

.bi-controls select,
.bi-controls button,
.history-refresh,
.snapshots-toolbar input,
.snapshots-toolbar select,
.snapshots-toolbar button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--surface);
  font-size: 12px;
}

.bi-controls button:hover:not(:disabled),
.history-refresh:hover:not(:disabled),
.snapshots-toolbar button:hover:not(:disabled) {
  background: var(--surface-hover);
}

.bi-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.bi-metrics article {
  min-height: 116px;
  padding: 18px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}

.bi-metrics article:last-child {
  border-right: 0;
  grid-column: auto / span 2;
}

.bi-metrics article:nth-child(4n) {
  border-right: 0;
}

.bi-metrics article:nth-child(n + 5) {
  border-top: 1px solid var(--line);
}

.bi-metrics .bi-metric--cost {
  color: var(--ink);
  background: var(--surface);
}

.bi-metrics span,
.bi-metrics .bi-metric--cost span,
.bi-metrics small,
.bi-metrics .bi-metric--cost small {
  color: var(--muted);
}

.bi-metrics strong {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 540;
  letter-spacing: -0.045em;
}

.bi-panel {
  padding: 18px;
}

.bi-panel > header {
  border-bottom: 1px solid var(--line);
}

.bi-daily-chart {
  gap: 6px;
}

.bi-daily-bar__value {
  border-radius: 4px 4px 0 0;
  background: #8a8a8a;
}

.bi-table th {
  color: var(--muted);
  background: var(--surface-subtle);
  font-weight: 550;
}

.bi-table td,
.bi-table th {
  border-color: var(--line);
}

.bi-rate-note {
  border-color: #ead9ad;
  border-radius: 10px;
  background: #fffaf0;
}

.free-quota-card {
  padding: 20px;
}

.free-quota-card__header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.free-quota-bar__track {
  height: 7px;
  background: #ececec;
}

.free-quota-bar__value {
  background: transparent;
}

.history-layout,
.snapshots-layout {
  gap: 12px;
}

.history-list-panel,
.snapshots-list-panel {
  background: var(--surface-subtle);
}

.history-list-item,
.snapshots-list-item {
  margin: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
}

.history-list-item:hover,
.snapshots-list-item:hover {
  border-color: var(--line);
  background: var(--surface);
}

.history-list-item[aria-pressed="true"],
.snapshots-list-item[aria-pressed="true"] {
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: none;
}

.history-detail,
.snapshot-detail {
  padding: 20px;
}

.history-detail__metrics > div,
.snapshot-detail__sections > section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.snapshots-toolbar {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-subtle);
}

.settings-view .bi-header {
  margin-bottom: 0;
}

.settings-form,
.integration-connect-card {
  border-radius: 12px;
}

.settings-section-heading h3,
.integration-connect-card__header h3 {
  font-size: 15px;
  font-weight: 620;
}

.settings-grid {
  gap: 12px;
}

.settings-panel {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-subtle);
}

.telegram-chat {
  width: min(900px, 100%);
  height: calc(100vh - 206px);
  min-height: 620px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: none;
}

.telegram-chat__header {
  min-height: 64px;
  padding: 10px 14px;
  border-color: var(--line);
  background: var(--surface);
}

.telegram-avatar {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: #111;
  box-shadow: none;
}

.telegram-chat__header h2 {
  font-size: 14px;
  font-weight: 620;
}

.telegram-chat__header p {
  color: var(--muted);
}

.telegram-chat__refresh {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--surface);
  font-weight: 550;
}

.telegram-chat__refresh:hover:not(:disabled) {
  border-color: #b7b7b7;
  color: var(--ink);
  background: var(--surface-hover);
}

.telegram-chat__analysis {
  border-color: #111;
  color: #fff;
  background: #111;
}

.telegram-chat__analysis:hover:not(:disabled) {
  border-color: #2b2b2b;
  color: #fff;
  background: #2b2b2b;
}

.chat-pinned-analysis {
  border-color: var(--line);
  background: var(--surface-subtle);
}

.chat-conversation {
  background: var(--surface);
}

.chat-empty {
  background: var(--surface);
}

.chat-empty__icon {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: #111;
  font-size: 12px;
  font-weight: 700;
  box-shadow: none;
}

.chat-empty h3 {
  color: var(--ink);
  font-size: 17px;
  font-weight: 620;
  letter-spacing: -0.015em;
}

.chat-empty p {
  color: var(--muted);
}

.chat-empty button {
  border-radius: 8px;
  color: #fff;
  background: #111;
  font-weight: 600;
}

.chat-empty button:hover {
  background: #2b2b2b;
}

.chat-messages {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px 24px;
}

.chat-message {
  align-items: flex-start;
}

.chat-message__avatar {
  border-radius: 8px;
  box-shadow: none;
}

.chat-message__body {
  max-width: min(680px, 82%);
}

.chat-message--assistant .chat-bubble,
.chat-message--own .chat-bubble {
  border: 0;
  border-radius: 12px;
  box-shadow: none;
}

.chat-message--assistant .chat-bubble {
  padding: 9px 12px;
  background: #f1f3f5;
}

.chat-message--user .chat-bubble,
.chat-message--own .chat-bubble {
  background: #d4f2dc;
}

.chat-quick-prompts {
  width: min(760px, 100%);
  margin: 0 auto;
  border-color: var(--line);
  background: var(--surface);
}

.chat-quick-prompts button {
  border-color: var(--line-strong);
  color: #404040;
}

.chat-quick-prompts button:hover:not(:disabled) {
  background: var(--surface-hover);
}

.chat-composer {
  width: min(760px, calc(100% - 28px));
  margin: 0 auto 10px;
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.06);
}

.chat-composer textarea {
  border: 0;
  border-radius: 8px;
  background: var(--surface);
}

.chat-composer textarea:focus {
  border: 0;
  background: var(--surface);
  box-shadow: none;
}

.chat-send {
  border-radius: 9px;
  box-shadow: none;
}

.chat-status {
  color: var(--muted);
  background: var(--surface);
  text-align: center;
}

@media (max-width: 1100px) {
  .page-shell {
    width: min(100% - 40px, 920px);
  }

  .bi-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bi-metrics article:last-child {
    grid-column: auto;
  }

  .bi-metrics article:nth-child(2n) {
    border-right: 0;
  }

  .bi-metrics article:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .bi-metrics article:nth-child(2n + 1) {
    border-right: 1px solid var(--line);
  }
}

@media (max-width: 900px) {
  .app-sidebar {
    width: min(280px, calc(100vw - 48px));
    transform: translateX(-102%);
    box-shadow: 16px 0 44px rgba(0, 0, 0, 0.12);
    transition: transform 180ms ease;
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 35;
    inset: 0;
    display: block;
    visibility: hidden;
    border: 0;
    opacity: 0;
    background: rgba(0, 0, 0, 0.32);
    transition:
      visibility 180ms ease,
      opacity 180ms ease;
  }

  body.sidebar-open .sidebar-backdrop {
    visibility: visible;
    opacity: 1;
  }

  .app-main {
    margin-left: 0;
  }

  .mobile-topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: grid;
    height: 52px;
    grid-template-columns: 36px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
  }

  .mobile-topbar strong {
    font-size: 14px;
    font-weight: 650;
  }

  .mobile-topbar > span {
    color: var(--muted);
    font-size: 10px;
  }

  .sidebar-toggle {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
  }

  .sidebar-toggle:hover {
    background: var(--surface-hover);
  }

  .page-topbar {
    min-height: 100px;
    padding: 20px;
  }

  .page-shell {
    width: min(100% - 40px, 760px);
    padding-top: 22px;
  }

  .deal-overview,
  .deal-workspace,
  .history-layout,
  .snapshots-layout {
    grid-template-columns: 1fr;
  }

  .history-list-panel,
  .snapshots-list-panel {
    position: static;
    max-height: 360px;
  }

  .telegram-chat {
    height: calc(100vh - 196px);
  }
}

@media (max-width: 620px) {
  .page-topbar {
    min-height: 0;
    padding: 16px;
  }

  .page-topbar__eyebrow,
  .page-topbar .readonly-badge {
    display: none;
  }

  .page-topbar h1 {
    font-size: 21px;
  }

  .page-topbar h1 + p {
    max-width: 34rem;
    font-size: 12px;
  }

  .page-shell {
    width: calc(100% - 24px);
    padding: 14px 0 32px;
  }

  .command-card,
  .settings-form,
  .integration-connect-card,
  .results,
  .bi-panel,
  .free-quota-card,
  .history-detail,
  .snapshot-detail {
    padding: 14px;
    border-radius: 10px;
  }

  .workspace-tabs {
    display: grid;
    max-width: none;
    overflow: visible;
  }

  .workspace-tabs button {
    flex: none;
  }

  .bi-header,
  .free-quota-card__header,
  .bi-rate-note {
    display: grid;
    gap: 12px;
  }

  .bi-controls {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .bi-controls button {
    grid-column: 1 / -1;
  }

  .bi-metrics {
    grid-template-columns: 1fr;
  }

  .bi-metrics article,
  .bi-metrics article:nth-child(2n) {
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .bi-metrics article:first-child {
    border-top: 0;
  }

  .integration-connect-fields {
    grid-template-columns: 1fr;
  }

  .integration-connect-control,
  .integration-connect-control--token {
    grid-template-columns: 1fr 1fr;
  }

  .integration-connect-control input {
    grid-column: 1 / -1;
  }

  .telegram-chat {
    width: 100%;
    min-height: 520px;
    height: calc(100vh - 170px);
    border-radius: 10px;
  }

  .telegram-chat__header {
    align-items: flex-start;
  }

  .telegram-chat__actions {
    gap: 4px;
  }

  .telegram-chat__refresh {
    max-width: 88px;
    padding: 7px 8px;
  }

  .chat-messages {
    padding: 14px 10px;
  }

  .chat-message__body {
    max-width: 90%;
  }

  .chat-composer {
    width: calc(100% - 16px);
  }

  .history-detail__metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.chat-presets-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 70px rgb(15 23 42 / 24%);
}

.chat-presets-dialog::backdrop { background: rgb(15 23 42 / 38%); }
.chat-presets-dialog__header,
.chat-preset-form { padding: 18px; }
.chat-presets-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.chat-presets-dialog__header h2,
.chat-presets-dialog__header p { margin: 0; }
.chat-presets-dialog__header p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.chat-presets-dialog__header button { border: 0; background: transparent; font-size: 24px; }
.chat-presets-search {
  display: grid;
  gap: 6px;
  padding: 14px 18px 0;
  font-size: 12px;
  font-weight: 700;
}
.chat-presets-search input { width: 100%; box-sizing: border-box; }
.chat-presets-list { display: grid; gap: 8px; max-height: 330px; overflow: auto; padding: 14px 18px; }
.chat-preset-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.chat-preset-row__star {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #9ca3af;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.chat-preset-row__star[aria-pressed="true"] { color: #d89614; }
.chat-preset-row__copy strong,
.chat-preset-row__copy span { display: block; }
.chat-preset-row__copy span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.chat-preset-row__actions { display: flex; gap: 5px; }
.chat-preset-row__actions button { padding: 5px 8px; }
.chat-preset-form { display: grid; gap: 10px; border-top: 1px solid var(--line); }
.chat-preset-form label { display: grid; gap: 5px; font-size: 12px; font-weight: 700; }
.chat-preset-form input,
.chat-preset-form textarea { width: 100%; box-sizing: border-box; }
.chat-preset-form__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Restrained TKI workspace: neutral, conversation-first visual language. */
:root {
  --ink: #202123;
  --muted: #6f6f6b;
  --paper: #f7f7f5;
  --surface: #fff;
  --surface-subtle: #f2f2ef;
  --surface-hover: #eaeae6;
  --line: #e2e2de;
  --line-strong: #cacac5;
  --green: #087a5b;
  --green-dark: #056348;
  --green-soft: #e2f3ec;
  --focus-ring: rgba(8, 122, 91, 0.24);
  --radius-control: 10px;
  --radius-card: 14px;
  --content-width: 1160px;
  --reading-width: 760px;
  font-family: "Segoe UI Variable Text", "Segoe UI", Inter, ui-sans-serif, system-ui, sans-serif;
}

html { color-scheme: light; background: var(--paper); }
body { color: var(--ink); background: var(--paper); font-size: 14px; line-height: 1.5; }
::selection { color: var(--ink); background: #cfe9df; }
button, input, select, textarea { font: inherit; }
button { transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.app-sidebar { width: 248px; padding: 18px 12px 14px; border-color: var(--line); background: var(--surface-subtle); }
.sidebar-brand { min-height: 50px; padding: 4px 9px; }
.sidebar-brand__mark { width: 32px; height: 32px; flex-basis: 32px; border-radius: 9px; background: var(--ink); }
.sidebar-brand strong { font-size: 14px; font-weight: 650; }
.sidebar-brand div > span { color: var(--muted); font-size: 11px; }
.sidebar-environment { min-height: 40px; margin: 10px 2px 22px; padding: 6px 10px; border-radius: var(--radius-control); border-color: var(--line); background: rgba(255,255,255,.72); }
.sidebar-group-label { padding: 0 10px 8px; color: #858581; font-size: 10px; font-weight: 650; letter-spacing: .055em; }
.workspace-tabs { gap: 3px; }
.workspace-tabs button { min-height: 42px; padding: 9px 11px; border-radius: 9px; color: #575753; font-weight: 500; }
.workspace-tabs button:hover { background: var(--surface-hover); }
.workspace-tabs button[aria-selected="true"] { background: #dfdfda; font-weight: 620; }
.workspace-tabs button svg { stroke-width: 1.65; }
.app-main { margin-left: 248px; background: var(--paper); }

.page-topbar { position: sticky; z-index: 20; top: 0; min-height: 104px; padding: 22px 32px 18px; border-color: var(--line); background: rgba(247,247,245,.9); backdrop-filter: blur(16px) saturate(1.2); }
.page-topbar__eyebrow { margin-bottom: 6px; color: #81817c; font-size: 10px; }
.page-topbar h1 { font-size: clamp(23px, 2vw, 28px); font-weight: 590; letter-spacing: -.035em; }
.page-topbar h1 + p { max-width: 52rem; margin-top: 5px; color: var(--muted); }
.page-shell { width: min(var(--content-width), calc(100% - 64px)); padding: 32px 0 72px; }

.readonly-badge, .environment-badge, .status-badge, .panel-count, .integration-connect-badge {
  min-height: 26px; display: inline-flex; align-items: center; padding: 3px 9px; border-color: var(--line); color: #5d5d59; background: rgba(255,255,255,.74);
}
.command-card, .results, .error-log, .settings-form, .integration-connect-card, .bi-panel, .free-quota-card,
.history-list-panel, .history-detail, .snapshots-list-panel, .snapshot-detail, .deal-overview, .timeline-panel,
.side-panel, .technical-data, .result-card, .ai-analysis-panel {
  border-color: var(--line); border-radius: var(--radius-card); background: var(--surface);
}
.command-card, .settings-form, .integration-connect-card, .results, .history-detail, .snapshot-detail { padding: 24px; }
.section-heading h2, .results-header h2, .bi-header h2 { font-size: 17px; font-weight: 620; letter-spacing: -.02em; }
.result-kicker, .eyebrow { color: var(--green-dark); font-size: 10px; font-weight: 650; letter-spacing: .045em; text-transform: none; }
label { color: #555551; font-size: 12px; font-weight: 600; }
input, select, textarea, .integration-connect-control input { min-height: 44px; border-color: var(--line-strong); border-radius: var(--radius-control); background: var(--surface); }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: #ababaa; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
#submit-button, .integration-connect-button, .settings-actions button, .chat-send { min-height: 44px; border-radius: var(--radius-control); background: var(--ink); }
#submit-button:hover:not(:disabled), .integration-connect-button:hover:not(:disabled), .settings-actions button:hover:not(:disabled), .chat-send:hover:not(:disabled) { background: #37383a; }
.request-status, .snapshots-toolbar, .settings-panel { border-radius: var(--radius-control); background: var(--surface-subtle); }

.bi-header { align-items: end; gap: 24px; }
.bi-controls { grid-template-columns: minmax(160px,190px) minmax(120px,150px) auto; gap: 10px; }
.bi-controls select, .bi-controls button, .history-refresh, .snapshots-toolbar input, .snapshots-toolbar select, .snapshots-toolbar button { min-height: 42px; border-radius: var(--radius-control); }
.bi-status { border-radius: var(--radius-control); }
.bi-metrics { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; overflow: visible; border: 0; background: transparent; }
.bi-metrics article, .bi-metrics article:nth-child(n), .bi-metrics article:last-child { min-height: 132px; grid-column: auto; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.bi-metrics span { font-size: 11px; font-weight: 620; letter-spacing: .035em; }
.bi-metrics strong { font-size: clamp(26px,2.7vw,34px); font-weight: 520; font-variant-numeric: tabular-nums; }
.bi-metrics small { max-width: 32rem; line-height: 1.45; }
.bi-panel { padding: 22px; }
.bi-table-wrap { border: 1px solid var(--line); border-radius: var(--radius-control); }
.bi-table th { background: var(--surface-subtle); }
.bi-rate-note { border-color: #e9d8a7; background: #fffaf0; }

/* Desktop management report. Mobile-specific implementation is intentionally out of scope. */
#bi-view {
  max-width: 1500px;
  margin: 0 auto;
}

#bi-view .bi-header {
  align-items: end;
}

#bi-view .bi-controls {
  grid-template-columns: 150px 150px auto auto;
  align-items: end;
}

#bi-view .bi-controls select,
#bi-view .bi-controls input,
#bi-view .bi-controls button {
  min-height: 40px;
}

.bi-custom-range {
  display: grid;
  grid-template-columns: 150px 150px;
  gap: 8px;
}

.bi-custom-range[hidden] {
  display: none;
}

.bi-custom-range label {
  display: grid;
  gap: 5px;
}

.bi-custom-range input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface);
}

#bi-view .bi-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#bi-view .bi-metrics article,
#bi-view .bi-metrics article:nth-child(n) {
  min-height: 122px;
}

#bi-view .bi-metrics article[data-available="false"] strong {
  color: var(--muted);
}

.usage-empty {
  margin-top: 16px;
  padding: 36px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-card);
  text-align: center;
  background: var(--surface);
}

.usage-empty strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

.usage-empty p,
.usage-methodology p,
.usage-methodology li {
  color: var(--muted);
}

.usage-coverage-note strong {
  font-size: 14px;
  line-height: 1.45;
}

#bi-view .bi-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#bi-view .bi-panel--wide {
  grid-column: 1 / -1;
}

.usage-daily-row {
  display: grid;
  grid-template-columns: 78px minmax(160px, 1fr) 54px 74px;
  gap: 12px;
  align-items: center;
  min-height: 34px;
  font-size: 13px;
}

.usage-daily-row time,
.usage-daily-row small {
  color: var(--muted);
}

.usage-daily-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-subtle);
}

.usage-daily-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.usage-user-table td:first-child {
  min-width: 240px;
  font-weight: 600;
}

.usage-methodology ul {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
  padding-left: 20px;
}
.history-list-panel, .snapshots-list-panel { background: var(--surface-subtle); }
.history-list-item, .snapshot-list-item { min-height: 64px; margin: 5px; border-radius: var(--radius-control); }
.history-list-item[aria-pressed="true"], .snapshot-list-item[aria-pressed="true"] { border-color: var(--line-strong); }

.telegram-chat { width: min(940px,100%); height: calc(100dvh - 208px); min-height: 600px; border-radius: var(--radius-card); background: var(--surface); }
.telegram-chat__header { min-height: 68px; padding: 12px 16px; }
.telegram-avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--ink); }
.telegram-chat__header h2 { font-size: 15px; font-weight: 620; }
.telegram-chat__refresh { min-height: 40px; border-radius: var(--radius-control); }
.telegram-chat__analysis { background: var(--ink); }
.chat-conversation { scrollbar-color: #c4c4bf transparent; }
.chat-empty { max-width: 520px; margin: auto; padding: 48px 24px; }
.chat-empty__icon { width: 48px; height: 48px; border-radius: 14px; background: var(--ink); }
.chat-empty h3 { font-size: 20px; font-weight: 590; }
.chat-empty p { max-width: 440px; line-height: 1.6; }
.chat-messages { width: min(var(--reading-width),100%); padding: 24px 20px 18px; }
.chat-message { gap: 10px; }
.chat-message__body { max-width: min(660px,86%); }
.chat-message__avatar { width: 28px; height: 28px; border-radius: 9px; background: var(--ink); }
.chat-message--assistant .chat-bubble { padding: 10px 12px; background: var(--surface-subtle); }
.chat-message--user .chat-bubble, .chat-message--own .chat-bubble { background: var(--green-soft); }
.chat-bubble__content { font-size: 14px; line-height: 1.55; }
.chat-bubble__content .chat-citation { background: #dceee7; color: var(--green-dark); }
.chat-bubble__details > summary { min-height: 26px; display: inline-flex; align-items: center; }
.chat-quick-prompts { width: min(var(--reading-width),100%); padding: 10px 14px; }
.chat-quick-prompts button { min-height: 36px; border-radius: 999px; }
.chat-composer { width: min(var(--reading-width),calc(100% - 28px)); margin-bottom: 14px; padding: 8px; border-color: var(--line-strong); border-radius: 18px; box-shadow: 0 8px 28px rgba(32,33,35,.08); }
.chat-composer:focus-within { border-color: #aaa; box-shadow: 0 8px 30px rgba(32,33,35,.1), 0 0 0 3px var(--focus-ring); }
.chat-composer textarea { min-height: 48px; padding: 13px 64px 10px 12px; line-height: 1.45; }
.chat-send { width: 42px; height: 42px; min-height: 42px; border-radius: 12px; }
.chat-status { min-height: 24px; }
.chat-presets-dialog { border-radius: var(--radius-card); box-shadow: 0 24px 72px rgba(32,33,35,.2); }
.chat-presets-dialog::backdrop { background: rgba(32,33,35,.42); backdrop-filter: blur(2px); }
.chat-preset-row { min-height: 64px; border-radius: var(--radius-control); }
.chat-preset-row__actions button { min-height: 36px; }

@media (max-width: 1100px) {
  .bi-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .bi-metrics article:nth-child(n) { border: 1px solid var(--line); }
}
@media (max-width: 900px) {
  .app-sidebar { width: min(288px,calc(100vw - 44px)); }
  .app-main { margin-left: 0; }
  .mobile-topbar { height: 56px; background: rgba(247,247,245,.92); }
  .sidebar-toggle { width: 44px; height: 44px; margin-left: -5px; }
  .page-topbar { position: static; min-height: 96px; padding: 19px 24px 17px; }
  .page-shell { width: min(100% - 40px,780px); padding-top: 24px; }
  .telegram-chat { height: calc(100dvh - 190px); min-height: 540px; }
}
@media (max-width: 620px) {
  .page-topbar { padding: 17px 16px 15px; }
  .page-topbar h1 { font-size: 22px; }
  .page-shell { width: calc(100% - 24px); padding: 16px 0 40px; }
  .command-card, .settings-form, .integration-connect-card, .results, .bi-panel, .free-quota-card, .history-detail, .snapshot-detail { padding: 16px; border-radius: 12px; }
  .command-row, .bi-controls, .bi-metrics { grid-template-columns: 1fr; }
  .bi-controls button { grid-column: auto; min-height: 44px; }
  .bi-metrics { gap: 8px; }
  .bi-metrics article:nth-child(n) { min-height: 112px; padding: 17px; }
  .bi-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .bi-table { min-width: 820px; }
  .telegram-chat { min-height: 500px; height: calc(100dvh - 166px); border-radius: 12px; }
  .telegram-chat__header { min-height: 62px; padding: 10px 12px; }
  .telegram-chat__actions button { min-width: 44px; min-height: 44px; }
  .chat-messages { padding: 18px 10px; }
  .chat-message__body { max-width: calc(100% - 38px); }
  .chat-bubble__content { font-size: 13px; }
  .chat-quick-prompts { padding-inline: 10px; }
  .chat-quick-prompts button { min-height: 40px; }
  .chat-composer { width: calc(100% - 16px); margin-bottom: 8px; border-radius: 16px; }
  .history-detail__metrics { grid-template-columns: 1fr; }
  .chat-presets-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .chat-preset-row { grid-template-columns: auto minmax(0,1fr); }
  .chat-preset-row__actions { grid-column: 2; flex-wrap: wrap; }
}
@media (prefers-contrast: more) {
  :root { --line: #b3b3ae; --line-strong: #888884; }
  .readonly-badge, .status-badge, .panel-count { border-width: 2px; }
}
