:root {
  color-scheme: light;
  --ink: #182522;
  --ink-soft: #40504a;
  --muted: #74817b;
  --line: #dfe7e1;
  --line-strong: #ccd9d1;
  --canvas: #f5f7f5;
  --panel: #ffffff;
  --panel-soft: #eef4ef;
  --sidebar: #1c2b27;
  --sidebar-soft: #2a3c35;
  --sidebar-text: #eaf1eb;
  --green: #287456;
  --green-dark: #18523d;
  --green-soft: #e0eee5;
  --amber: #b97820;
  --amber-soft: #fff1d7;
  --danger: #a64138;
  --danger-soft: #fbe9e6;
  --shadow: 0 12px 35px rgba(31, 54, 44, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(40, 116, 86, 0.28);
  outline-offset: 2px;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  flex: 0 0 auto;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 24px 16px 18px;
  background: var(--sidebar);
  color: var(--sidebar-text);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(234, 241, 235, 0.25);
  border-radius: 10px;
  background: #315244;
  color: #f7fbf7;
  font-size: 19px;
  font-weight: 700;
}

.brand-copy {
  display: grid;
  line-height: 1.15;
}

.brand-copy strong {
  font-size: 16px;
  font-weight: 650;
}

.brand-copy span {
  margin-top: 3px;
  color: #a9bcb1;
  font-size: 12px;
}

.new-session {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 42px;
  margin-top: 31px;
  border: 1px solid rgba(225, 242, 230, 0.2);
  border-radius: 7px;
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.new-session:hover {
  border-color: rgba(225, 242, 230, 0.42);
  background: var(--sidebar-soft);
}

.sidebar-label {
  margin: 28px 10px 9px;
  color: #91a69a;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-list {
  display: grid;
  gap: 4px;
  min-width: 0;
  max-height: min(360px, 46vh);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(225, 242, 230, 0.24) transparent;
}

.history-empty {
  min-height: 40px;
  padding: 11px;
  color: #81968a;
  font-size: 12px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 11px;
  border-radius: 6px;
  background: transparent;
  color: #c5d3c9;
  text-align: left;
  cursor: pointer;
}

.history-item:hover,
.history-item.active {
  background: var(--sidebar-soft);
  color: #ffffff;
}

.history-item span {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-chevron {
  width: 15px;
  height: 15px;
  margin-left: auto;
  color: #8ca095;
}

.sidebar-spacer {
  flex: 1;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px 0;
  border-top: 1px solid rgba(229, 242, 233, 0.12);
  color: #aabdb1;
  font-size: 12px;
}

.sidebar-badge,
.preview-tag,
.status-pill,
.row-status {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
}

.sidebar-badge {
  margin-left: auto;
  padding: 2px 7px;
  background: rgba(211, 235, 218, 0.13);
  color: #c8e6ce;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #54b77d;
  box-shadow: 0 0 0 3px rgba(84, 183, 125, 0.13);
  flex: 0 0 auto;
}

.main-column {
  display: flex;
  min-width: 0;
  min-height: 100dvh;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 34px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
}

.topbar-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
}

.preview-tag {
  padding: 3px 8px;
  background: var(--amber-soft);
  color: var(--amber);
}

.topbar-user-wrap {
  position: relative;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 4px 7px 4px 5px;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.user-chip:hover {
  background: var(--panel-soft);
}

.avatar {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--green-dark);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.user-copy {
  display: grid;
  min-width: 0;
  line-height: 1.2;
}

.user-copy strong {
  font-size: 13px;
  font-weight: 650;
}

.user-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.user-chevron {
  width: 15px;
  height: 15px;
  margin-left: 5px;
  color: var(--muted);
}

.user-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  min-width: 210px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink-soft);
  font-size: 12px;
}

.user-popover[hidden] {
  display: none;
}

.popover-title {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.popover-note {
  color: var(--amber);
}

.popover-divider {
  height: 1px;
  margin: 12px 0;
  background: var(--line);
}

.popover-action {
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font-size: 12px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.popover-action:hover {
  color: var(--green-dark);
}

.conversation {
  display: flex;
  width: min(100%, 980px);
  flex: 1;
  flex-direction: column;
  align-self: center;
  padding: 50px 42px 28px;
}

.welcome {
  width: min(100%, 730px);
  margin: auto auto 30px;
  text-align: center;
}

.welcome h1 {
  margin: 0;
  color: var(--ink);
  font-size: 30px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.3;
  text-wrap: balance;
}

.welcome-emoji {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.9em;
  vertical-align: 0.04em;
}

.messages {
  display: grid;
  gap: 25px;
  width: 100%;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.message.user {
  grid-template-columns: minmax(0, 1fr);
  justify-items: end;
}

.message-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: var(--green-dark);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.message.user .message-bubble {
  max-width: min(80%, 580px);
  padding: 11px 14px;
  border-radius: 8px 8px 2px 8px;
  background: var(--green-dark);
  color: #ffffff;
}

.message-bubble {
  min-width: 0;
}

.message-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 9px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

.message-time {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.result-panel {
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 5px 18px rgba(31, 54, 44, 0.045);
}

.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.result-heading h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 680;
}

.result-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  padding: 4px 8px;
  background: var(--amber-soft);
  color: var(--amber);
}

.metrics-table {
  width: 100%;
  margin-top: 4px;
  border-collapse: collapse;
}

.detail-table-wrap {
  margin-top: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.detail-table {
  min-width: 650px;
}

.detail-table td {
  white-space: nowrap;
}

.detail-id {
  color: var(--muted) !important;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px !important;
}

.detail-count {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.metrics-table th,
.metrics-table td {
  padding: 13px 7px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.metrics-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.metrics-table td {
  color: var(--ink-soft);
  font-size: 13px;
}

.metrics-table td:first-child {
  color: var(--ink);
  font-weight: 600;
}

.metric-value {
  color: var(--ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 680;
}

.metric-unit {
  color: var(--muted);
  font-size: 12px;
}

.row-status {
  padding: 3px 7px;
  background: var(--green-soft);
  color: var(--green-dark);
}

.data-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 15px;
  padding: 10px 11px;
  border-left: 3px solid #d59c48;
  background: #fff9ed;
  color: #6f552d;
  font-size: 12px;
}

.data-note .icon {
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.limitations {
  margin-top: 13px;
  color: var(--muted);
  font-size: 12px;
}

.limitations summary {
  width: fit-content;
  cursor: pointer;
  color: var(--green);
  font-weight: 600;
}

.limitations ul {
  margin: 9px 0 0 17px;
  padding: 0;
}

.file-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 15px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.file-info {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.file-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: #d3e7d9;
  color: var(--green-dark);
}

.file-copy {
  display: grid;
  min-width: 0;
}

.file-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--green);
  color: #ffffff;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: background 160ms ease;
}

.download-button:hover {
  background: var(--green-dark);
}

.blocked-panel {
  padding: 14px 15px;
  border: 1px solid #efc7c1;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
}

.message-panel {
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.message-panel p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
}

.blocked-panel strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.blocked-panel p {
  margin: 0;
  font-size: 12px;
}

.loading-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.loading-bubble span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.1s ease-in-out infinite;
}

.loading-bubble span:nth-child(2) { animation-delay: 120ms; }
.loading-bubble span:nth-child(3) { animation-delay: 240ms; }

@keyframes pulse {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.composer-zone {
  width: min(100%, 980px);
  align-self: center;
  padding: 0 42px 26px;
}

.composer-context {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  color: var(--muted);
  font-size: 11px;
}

.composer-context label {
  font-weight: 600;
}

.composer-context select {
  padding: 3px 21px 3px 3px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.context-divider {
  width: 1px;
  height: 13px;
  background: var(--line-strong);
}

.context-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.context-status .status-dot {
  width: 6px;
  height: 6px;
  box-shadow: none;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  min-height: 64px;
  padding: 11px 12px 11px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(31, 54, 44, 0.06);
}

.composer:focus-within {
  border-color: #8bb69a;
  box-shadow: 0 8px 24px rgba(31, 94, 67, 0.11);
}

.composer textarea {
  width: 100%;
  min-height: 38px;
  max-height: 130px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.45;
}

.composer textarea::placeholder {
  color: #98a7a0;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 11px;
}

.composer-hint {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.send-button,
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 7px;
  cursor: pointer;
}

.send-button {
  background: var(--green-dark);
  color: #ffffff;
  transition: background 160ms ease, transform 160ms ease;
}

.send-button:hover {
  background: #103b2c;
  transform: translateY(-1px);
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.icon-button {
  background: transparent;
  color: var(--ink-soft);
}

.mobile-menu {
  display: none;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--ink);
  color: #ffffff;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.mobile-scrim {
  display: none;
}

.login-overlay {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 35, 29, 0.42);
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  width: min(100%, 390px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 55px rgba(20, 35, 29, 0.18);
}

.login-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 10px;
  background: var(--green-dark);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
}

.login-eyebrow {
  margin: 20px 0 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 650;
}

.login-card h1 {
  margin: 0;
  color: var(--ink);
  font-size: 25px;
  font-weight: 680;
  letter-spacing: 0;
}

.login-description {
  margin: 8px 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

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

.login-form label {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

.login-form input {
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 0;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

.login-form input:focus {
  border-color: #8bb69a;
  box-shadow: 0 0 0 3px rgba(31, 94, 67, 0.11);
}

.login-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.login-submit {
  min-height: 42px;
  margin-top: 13px;
  border-radius: 6px;
  background: var(--green-dark);
  color: #ffffff;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.login-submit:hover {
  background: #103b2c;
}

.password-cancel {
  min-height: 36px;
  margin-top: 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.password-cancel:hover {
  color: var(--ink-soft);
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(286px, 88vw);
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu {
    display: inline-grid;
  }

  .topbar {
    height: 64px;
    padding: 0 16px;
  }

  .topbar-heading {
    margin-right: auto;
    margin-left: 9px;
  }

  .user-copy,
  .user-chevron {
    display: none;
  }

  .user-chip {
    padding-right: 0;
  }

  .conversation {
    padding: 34px 18px 22px;
  }

  .composer-zone {
    padding: 0 18px 16px;
  }

  .mobile-scrim:not([hidden]) {
    position: fixed;
    z-index: 30;
    inset: 0;
    display: block;
    background: rgba(20, 35, 29, 0.35);
  }
}

@media (max-width: 560px) {
  .welcome {
    margin-bottom: 24px;
  }

  .welcome h1 {
    font-size: 25px;
  }

  .result-panel {
    padding: 15px 12px;
  }

  .result-heading {
    display: grid;
    gap: 8px;
  }

  .metrics-table th,
  .metrics-table td {
    padding: 11px 4px;
  }

  .metrics-table th:nth-child(3),
  .metrics-table td:nth-child(3) {
    display: none;
  }

  .detail-table {
    min-width: 650px;
  }

  .detail-table th:nth-child(3),
  .detail-table td:nth-child(3) {
    display: table-cell;
  }

  .file-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .download-button {
    width: 100%;
  }

  .composer-context {
    gap: 7px;
  }

  .composer-hint {
    display: none;
  }

  .composer {
    min-height: 60px;
    padding-left: 12px;
  }
}
