:root {
  --bg: #f7f2e9;
  --bg-soft: #fffaf2;
  --ink: #192733;
  --muted: #6d7882;
  --line: rgba(25, 39, 51, 0.1);
  --line-strong: rgba(25, 39, 51, 0.16);
  --panel: rgba(255, 251, 245, 0.82);
  --panel-strong: #fffdf8;
  --navy: #1d2a35;
  --navy-soft: #253340;
  --accent: #b9522e;
  --accent-dark: #943c1d;
  --accent-soft: rgba(185, 82, 46, 0.12);
  --gold: #d19c33;
  --sea: #0d6e6e;
  --user-bubble: #dfe8e2;
  --assistant-bubble: #f2ede4;
  --shadow: 0 24px 60px rgba(28, 38, 49, 0.08);
  --shadow-soft: 0 10px 28px rgba(28, 38, 49, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans TC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(209, 156, 51, 0.12), transparent 24%),
    radial-gradient(circle at right 15%, rgba(13, 110, 110, 0.08), transparent 24%),
    linear-gradient(180deg, #fbf8f1 0%, #f3ecdf 100%);
}

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

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(209, 156, 51, 0.22);
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 26px 22px 22px;
  color: white;
  background:
    radial-gradient(circle at top left, rgba(209, 156, 51, 0.14), transparent 24%),
    linear-gradient(180deg, #192531 0%, #1f2d39 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-lockup {
  display: grid;
  gap: 8px;
}

.sidebar h1,
.hero h2 {
  margin: 0;
}

.sidebar h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 34px;
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

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

.subtle-light {
  color: rgba(255, 255, 255, 0.72);
}

.hidden {
  display: none !important;
}

.auth-copy {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.68);
}

#google-signin-button {
  width: 100%;
  min-width: 0;
}

#google-signin-button > div,
#google-signin-button iframe {
  max-width: 100%;
}

.auth-user-meta {
  min-width: 0;
}

.auth-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.12);
}

#auth-email {
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.68);
  word-break: break-all;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-btn,
.primary-btn,
.secondary-btn,
.send-icon-btn {
  border: 0;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

.nav-btn {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 0 16px;
  border-radius: 18px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

.nav-btn.active {
  background: linear-gradient(135deg, rgba(185, 82, 46, 0.96), rgba(148, 60, 29, 1));
  box-shadow: 0 14px 28px rgba(185, 82, 46, 0.32);
}

.nav-btn:hover,
.primary-btn:hover,
.secondary-btn:hover,
.send-icon-btn:hover {
  transform: translateY(-1px);
}

.account-area {
  position: relative;
  margin-top: auto;
}

.account-trigger {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  color: white;
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
}

.account-trigger-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 14px;
  font-weight: 700;
}

.account-trigger-copy {
  min-width: 0;
}

.account-trigger-copy strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
  color: white;
  font-weight: 500;
}

#account-trigger-meta {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 15;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  background: rgba(38, 45, 51, 0.96);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(16px);
}

.account-menu-user {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.account-menu-user strong {
  display: block;
  color: white;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 500;
}

.account-menu-divider {
  height: 1px;
  margin: 14px 0;
  background: rgba(255, 255, 255, 0.12);
}

.account-menu-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  color: white;
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
  font-weight: 600;
}

.content {
  position: relative;
  padding: 26px;
  height: 100vh;
  overflow: hidden;
}

.auth-placeholder {
  position: absolute;
  inset: 26px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.auth-placeholder-card {
  width: min(420px, calc(100% - 48px));
  padding: 26px 28px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 28px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
  text-align: center;
}

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

.auth-placeholder-card h2 {
  margin-bottom: 8px;
  font-size: 28px;
}

.auth-placeholder-card p {
  color: var(--muted);
  line-height: 1.7;
}

.loading-spinner,
.loading-spinner-inline {
  display: inline-flex;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(185, 82, 46, 0.18);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.loading-spinner-inline {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

.tab {
  display: none;
  min-height: 0;
}

.tab.active {
  display: block;
}

#tab-chat.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.hero h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.04;
  letter-spacing: -0.04em;
  font-weight: 500;
}

.hero-chat {
  margin-bottom: 20px;
}

.hero-actions {
  justify-content: flex-end;
}

.grid {
  display: grid;
  gap: 18px;
}

.chat-grid {
  grid-template-columns: 320px minmax(0, 1fr);
  align-items: stretch;
  min-height: 0;
}

.panel {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.chat-list-panel,
.chat-panel {
  min-height: 0;
  height: 100%;
}

.chat-list-panel {
  padding: 20px;
  overflow: hidden;
}

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

.panel:not(.chat-panel) {
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h3 {
  margin: 0;
  font-size: 18px;
}

.chat-head {
  margin: 0;
  padding: 22px 24px 16px;
  border-bottom: 1px solid rgba(25, 39, 51, 0.06);
}

.chat-head-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(25, 39, 51, 0.05);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

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

.strategy-month-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  margin-bottom: 18px;
  border: 1px solid rgba(25, 39, 51, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
}

.strategy-month-copy .label {
  font-size: 12px;
  color: var(--muted);
}

.strategy-month-copy .value {
  margin-top: 6px;
  font-size: 30px;
  line-height: 1;
  font-weight: 500;
  color: var(--ink);
}

.strategy-month-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.strategy-month-pill {
  min-height: 50px;
  padding: 0 18px;
  border: 1px solid rgba(25, 39, 51, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease,
    transform 160ms ease;
}

.strategy-month-pill:hover {
  transform: translateY(-1px);
  border-color: rgba(185, 82, 46, 0.2);
}

.strategy-month-pill.is-active {
  border-color: rgba(185, 82, 46, 0.24);
  background: linear-gradient(135deg, rgba(185, 82, 46, 0.16), rgba(185, 82, 46, 0.08));
  color: var(--ink);
}

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

.strategy-performance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.strategy-usage-card {
  padding: 14px 16px;
  border: 1px solid rgba(25, 39, 51, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
}

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

.strategy-card-edit {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(25, 39, 51, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.strategy-card-edit:hover {
  border-color: rgba(185, 82, 46, 0.24);
  background: rgba(185, 82, 46, 0.08);
  color: var(--accent-dark);
}

.strategy-usage-card .label {
  font-size: 12px;
  color: var(--muted);
}

.strategy-usage-card .value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
}

.strategy-editor {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(25, 39, 51, 0.08);
}

.strategy-editor-head {
  align-items: flex-start;
  margin-bottom: 16px;
}

.strategy-editor-head h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
}

.strategy-editor-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.strategy-editor-close {
  min-height: 42px;
  padding: 0 16px;
}

.strategy-prompt-panel {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid rgba(25, 39, 51, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.7);
}

.strategy-prompt-head {
  margin-bottom: 14px;
}

.strategy-prompt-head h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
}

#strategy-save-status {
  min-height: 20px;
  text-align: right;
}

#strategy-save-status.is-dirty {
  color: var(--accent-dark);
}

#strategy-save-status.is-saved {
  color: var(--sea);
}

.strategy-prompt-panel textarea {
  margin-top: 6px;
}

.strategy-prompt-panel .actions {
  margin-top: 16px;
}

.form-row {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

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

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--panel-strong);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(185, 82, 46, 0.34);
  box-shadow: 0 0 0 4px rgba(185, 82, 46, 0.08);
}

textarea {
  resize: vertical;
}

.primary-btn,
.secondary-btn {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  font-weight: 700;
}

.primary-btn {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 14px 30px rgba(185, 82, 46, 0.2);
}

.secondary-btn {
  color: var(--ink);
  background: rgba(25, 39, 51, 0.06);
}

.primary-btn.is-loading,
.secondary-btn.is-loading {
  pointer-events: none;
  opacity: 0.9;
}

.primary-btn.is-loading .btn-label,
.secondary-btn.is-loading .btn-label {
  opacity: 0.92;
}

.button-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
  vertical-align: -3px;
}

.actions,
.upload-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.test-data-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.test-data-toolbar-main {
  display: grid;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.test-data-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.test-data-filters input,
.test-data-filters select {
  max-width: 280px;
}

.empty-state {
  padding: 18px 0 6px;
  color: var(--muted);
}

.test-script-grid-wrap {
  max-height: calc(100vh - 260px);
  border: 1px solid rgba(25, 39, 51, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.6);
}

.script-table {
  width: auto;
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.script-table th,
.script-table td {
  padding: 6px 8px;
  border-right: 1px solid rgba(25, 39, 51, 0.08);
  border-bottom: 1px solid rgba(25, 39, 51, 0.08);
  background: rgba(255, 253, 248, 0.92);
  vertical-align: middle;
  overflow: hidden;
}

.script-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 36px;
  padding-top: 0;
  padding-bottom: 0;
  background: rgba(246, 240, 231, 0.98);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.table-control {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid rgba(25, 39, 51, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 13px;
}

.test-script-actions {
  text-align: center;
}

#test-script-table tr.row-flash {
  animation: rowFlash 1.8s ease;
}

#test-script-table tr.row-removing {
  opacity: 0.42;
  transition: opacity 0.2s ease;
}

@keyframes rowFlash {
  0% {
    background: rgba(192, 88, 44, 0.18);
  }
  100% {
    background: transparent;
  }
}

.row-action-btn {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(25, 39, 51, 0.08);
  border-radius: 10px;
  background: rgba(25, 39, 51, 0.04);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
}

.row-action-btn.danger {
  color: var(--accent-dark);
  background: rgba(185, 82, 46, 0.08);
  border-color: rgba(185, 82, 46, 0.16);
}

.script-table col {
  width: 96px;
}

.script-table .col-project_code,
.script-table .col-approved_rate,
.script-table .col-approved_amount_wan,
.script-table .col-term_months,
.script-table .col-lock_in_months,
.script-table .col-origination_fee,
.script-table .col-name,
.script-table .col-job_title,
.script-table .col-annual_income_wan,
.script-table .col-authorized,
.script-table .col-auth_level,
.script-table .col-auth_status,
.script-table .col-loan_confirmed,
.script-table .col-rate_confirmed,
.script-table .col-final_rate,
.script-table .col-final_amount_wan {
  width: 86px;
}

.script-table .col-company {
  width: 124px;
}

.script-table .col-auth_level,
.script-table .col-auth_status,
.script-table .col-loan_confirmed,
.script-table .col-rate_confirmed {
  width: 118px;
}

.script-table .col-workflow_note {
  width: 176px;
}

.script-table .col-last_updated {
  width: 128px;
}

.script-table .col-actions {
  width: 64px;
}

.updated-cell {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
}

.list {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  padding-right: 4px;
}

.skeleton-list {
  display: grid;
  gap: 12px;
}

.skeleton-card,
.skeleton-bubble {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(230, 223, 211, 0.9), rgba(244, 238, 229, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.skeleton-card {
  height: 84px;
  border: 1px solid rgba(25, 39, 51, 0.05);
  border-radius: 20px;
}

.list-item {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(25, 39, 51, 0.06);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  text-align: left;
}

.list-item strong {
  font-size: 16px;
}

.list-item.active {
  border-color: rgba(185, 82, 46, 0.3);
  background: linear-gradient(180deg, rgba(185, 82, 46, 0.12), rgba(255, 255, 255, 0.94));
}

.chat-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  height: 100%;
  padding: 0 20px 20px;
}

.chat-case-panel {
  margin: 6px 4px 8px;
  padding: 14px 16px;
  border: 1px solid rgba(25, 39, 51, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.76);
}

.chat-case-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.chat-case-item {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(25, 39, 51, 0.04);
}

.chat-case-item .label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}

.chat-case-item .value {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  word-break: break-word;
}

.messages {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 10px 4px 18px;
}

.messages-skeleton {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 10px 4px 18px;
}

.skeleton-bubble {
  height: 72px;
  border-radius: 24px;
}

.skeleton-bubble.assistant {
  width: min(62%, 520px);
  border-bottom-left-radius: 10px;
}

.skeleton-bubble.user {
  width: min(34%, 280px);
  margin-left: auto;
  border-bottom-right-radius: 10px;
}

.skeleton-bubble.wide {
  width: min(78%, 680px);
}

.message-row {
  display: flex;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.message {
  max-width: min(76%, 780px);
  padding: 16px 18px;
  border-radius: 24px;
  line-height: 1.8;
  font-size: 16px;
  white-space: pre-wrap;
  box-shadow: var(--shadow-soft);
}

.message.user {
  background: var(--user-bubble);
  border-bottom-right-radius: 10px;
}

.message.assistant {
  background: var(--assistant-bubble);
  border-bottom-left-radius: 10px;
}

.message.markdown {
  white-space: normal;
}

.message.markdown > *:first-child {
  margin-top: 0;
}

.message.markdown > *:last-child {
  margin-bottom: 0;
}

.message.markdown p,
.message.markdown ul,
.message.markdown ol,
.message.markdown pre {
  margin: 0 0 14px;
}

.message.markdown ul,
.message.markdown ol {
  padding-left: 22px;
}

.message.markdown li + li {
  margin-top: 6px;
}

.message.markdown strong {
  font-weight: 600;
}

.message.markdown code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(25, 39, 51, 0.08);
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 0.92em;
}

.message.markdown pre {
  padding: 12px 14px;
  border-radius: 16px;
  overflow: auto;
  background: rgba(25, 39, 51, 0.08);
}

.message.markdown pre code {
  display: block;
  padding: 0;
  background: transparent;
}

.message.markdown a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.message.loading {
  color: var(--muted);
}

.message-loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.ai-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 14px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 18px 40px rgba(25, 39, 51, 0.08);
}

.ai-composer textarea {
  min-height: 64px;
  max-height: 180px;
  padding: 8px 10px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  resize: none;
  line-height: 1.7;
}

.ai-composer textarea::placeholder {
  color: rgba(109, 120, 130, 0.9);
}

.send-icon-btn {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 16px 28px rgba(185, 82, 46, 0.24);
}

.send-icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.send-icon-btn.is-stopping {
  background: linear-gradient(135deg, var(--navy), var(--navy-soft));
  box-shadow: 0 16px 28px rgba(25, 39, 51, 0.18);
  opacity: 1;
}

.send-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 28px;
  transform: translateX(1px);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat {
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
}

.stat .label {
  font-size: 13px;
  color: var(--muted);
}

.stat .value {
  margin-top: 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 28px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(25, 39, 51, 0.08);
}

.pill {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill.low {
  background: rgba(13, 110, 110, 0.12);
  color: var(--sea);
}

.pill.medium {
  background: rgba(209, 156, 51, 0.14);
  color: #8f5c00;
}

.pill.high {
  background: rgba(185, 82, 46, 0.12);
  color: var(--accent);
}

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
}

.toast {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid rgba(25, 39, 51, 0.08);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 18px 40px rgba(25, 39, 51, 0.14);
  animation: toast-in 180ms ease;
}

.toast.success {
  border-color: rgba(13, 110, 110, 0.16);
}

.toast.error {
  border-color: rgba(185, 82, 46, 0.18);
}

.toast-title {
  font-size: 13px;
  font-weight: 700;
}

.toast-message {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1280px) {
  .chat-grid {
    grid-template-columns: 300px minmax(0, 1fr);
  }

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

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

  .test-data-toolbar {
    flex-direction: column;
  }

  .test-data-filters input,
  .test-data-filters select {
    max-width: none;
  }

  .content {
    height: auto;
    overflow: visible;
  }

  #tab-chat.active {
    display: block;
    height: auto;
  }

  .sidebar {
    gap: 16px;
  }

  .chat-grid,
  .stats-grid,
  .strategy-month-strip,
  .strategy-usage-grid,
  .strategy-performance-grid,
  .form-grid,
  .form-row.compact {
    grid-template-columns: 1fr;
  }

  .strategy-month-pills {
    justify-content: flex-start;
  }

  .chat-list-panel,
  .chat-panel {
    min-height: auto;
    height: auto;
  }

  .list {
    max-height: 360px;
  }
}

@media (max-width: 720px) {
  .content {
    padding: 18px;
  }

  .sidebar {
    padding: 20px 18px;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions {
    align-items: flex-end;
  }

  .chat-head {
    padding: 18px 18px 14px;
  }

  .chat-shell {
    padding: 0 14px 14px;
  }

  .message {
    max-width: 90%;
    font-size: 15px;
  }

  .ai-composer {
    grid-template-columns: minmax(0, 1fr) 56px;
    gap: 10px;
    padding: 10px;
  }

  .send-icon-btn {
    width: 56px;
    height: 56px;
    border-radius: 18px;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.shimmer::after {
  content: "";
  position: absolute;
  inset: -2px;
  transform: translateX(-120%);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.18) 18%,
    rgba(255, 255, 255, 0.78) 50%,
    rgba(255, 255, 255, 0.18) 82%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: shimmer 1.05s ease-in-out infinite;
}
