/* Transo dashboard — light theme + white sidebar */
:root {
  color-scheme: light;
  --transo-red: #d32f2f;
  --transo-red-dark: #b71c1c;
  --transo-red-soft: #ffebee;
  --transo-black: #121212;
  --transo-gray-600: #757575;
  --transo-gray-200: #e0e0e0;
  --transo-gray-50: #fafafa;
  --surface: #ffffff;
  --text: var(--transo-black);
  --muted: var(--transo-gray-600);
  --border: var(--transo-gray-200);
  --sidebar-w: 260px;
  --radius: 12px;
  --shadow-soft: 0 1px 3px rgba(18, 18, 18, 0.06);
  --shadow-card: 0 4px 24px rgba(18, 18, 18, 0.06);
  --font: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body.app {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--transo-gray-50);
  color: var(--text);
  display: flex;
}

/* ---- Sidebar (white) ---- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  z-index: 40;
  box-shadow: var(--shadow-soft);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--transo-red);
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  display: grid;
  place-items: center;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-size: 0.72rem;
  color: var(--muted);
}

.sidebar-nav {
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--transo-gray-50);
}

.nav-item.is-active {
  background: var(--transo-red-soft);
  color: var(--transo-red-dark);
  box-shadow: inset 3px 0 0 var(--transo-red);
}

.nav-icon {
  opacity: 0.55;
  font-size: 0.85rem;
}

.nav-item.is-active .nav-icon {
  opacity: 1;
  color: var(--transo-red);
}

a.nav-item-link {
  text-decoration: none;
  box-sizing: border-box;
  display: flex;
}

a.nav-item-link:hover {
  color: var(--text);
}

.sidebar-actions {
  padding: 0 14px 14px;
  flex-shrink: 0;
}

.btn-sidebar-reset {
  width: 100%;
  justify-content: center;
  font-size: 0.82rem;
  padding: 10px 12px;
  border: 1px solid var(--transo-red);
  border-radius: 10px;
  background: transparent;
  color: var(--transo-red-dark);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-sidebar-reset:hover {
  background: var(--transo-red-soft);
}

.sidebar-footer {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
}

.sidebar-footnote {
  margin: 0 0 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(18, 18, 18, 0.45);
  z-index: 35;
}

.sidebar-backdrop.is-visible {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ---- Main column ---- */
.shell {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px clamp(16px, 2.5vw, 32px);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
}

.topbar-copy {
  flex: 1;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-actions .btn {
  white-space: nowrap;
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar p {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #2e7d32;
  background: #e8f5e9;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.live-pill.is-offline {
  color: var(--transo-gray-600);
  background: #f5f5f5;
}
.live-pill.from-cache {
  color: #8a6d3b;
  background: #fcf6e3;
  border: 1px solid #f1e1a6;
}

.main {
  flex: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: clamp(16px, 2vw, 28px) clamp(12px, 2.5vw, 40px) 48px;
}

.view {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.view.is-visible {
  display: flex;
}

.reports-intro {
  margin-bottom: 4px;
}

.panel-title-large {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.lead-muted {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 720px;
}

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.kpi-card h3 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.kpi-card p {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--transo-red-dark);
}

.panel-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.panel-grow {
  flex: 1;
}

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

.panel-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.panel-hint {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel-head-wrap {
  align-items: flex-start;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filters-inline {
  justify-content: flex-end;
}

input,
select {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(211, 47, 47, 0.35);
  outline-offset: 1px;
  border-color: var(--transo-red);
}

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.12s, background 0.12s, border-color 0.12s;
}

.btn-primary {
  background: var(--transo-red);
  color: #fff;
  border-color: var(--transo-red);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover {
  border-color: var(--transo-red);
  color: var(--transo-red-dark);
}

.btn-export {
  min-width: 88px;
}

.muted {
  color: var(--muted);
  margin: 12px 0 0;
  font-size: 0.9rem;
}

.muted-tight {
  margin: 0 0 12px;
  font-size: 0.85rem;
}

/* Wide tables — use full viewport width, horizontal scroll on small screens */
.table-scroll-wide {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: min(72vh, 900px);
  -webkit-overflow-scrolling: touch;
}

.table-wide {
  width: 100%;
  min-width: min(1480px, 100%);
}

@media (min-width: 1400px) {
  .table-wide {
    min-width: 100%;
  }
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  table-layout: auto;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--transo-gray-50);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 1;
}

.th-sort {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  font-size: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  text-align: inherit;
  cursor: pointer;
  border-radius: 4px;
}

.th-sort:hover {
  color: var(--text);
}

.th-sort:focus-visible {
  outline: 2px solid var(--transo-red);
  outline-offset: 2px;
}

.sort-caret {
  display: inline-block;
  min-width: 0.65rem;
  font-size: 0.72rem;
  line-height: 1;
  opacity: 0;
}

.th-sort.is-active .sort-caret {
  opacity: 1;
}

.th-sort.is-active.is-asc .sort-caret::before {
  content: "\25b4"; /* ▴ */
}

.th-sort.is-active.is-desc .sort-caret::before {
  content: "\25be"; /* ▾ */
}

.data-table tbody tr:hover {
  background: #fff8f8;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.col-method {
  white-space: nowrap;
  width: 1%;
}
.col-ccy {
  white-space: nowrap;
  width: 1%;
}
.col-ref {
  white-space: nowrap;
}
.col-type {
  white-space: nowrap;
}
.col-amount {
  white-space: nowrap;
}
.col-party {
  white-space: normal;
  min-width: 220px;
  max-width: 420px;
}
.col-date {
  white-space: nowrap;
}
.col-balance {
  white-space: nowrap;
}
.col-device {
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-ccy {
  min-width: 2.75rem;
  text-align: center;
}

.badge-usd {
  background: #e8f4fd;
  color: #1565c0;
}

.badge-slsh {
  background: var(--transo-gray-50);
  color: var(--transo-gray-600);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-in {
  background: #e8f5e9;
  color: #1b5e20;
}

.badge-out {
  background: var(--transo-red-soft);
  color: var(--transo-red-dark);
}

.badge-fx {
  margin-left: 6px;
  background: #ede7f6;
  color: #4527a0;
  font-weight: 800;
}

.type-cell .badge {
  vertical-align: middle;
}

.badge-provider {
  background: #f5f5f5;
  color: var(--transo-black);
  font-weight: 700;
}

.chart-card-title {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.chart-card-desc {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}

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

.chart-card {
  background: linear-gradient(180deg, #fafafa 0%, var(--surface) 40%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 12px;
  box-shadow: var(--shadow-soft);
}

.chart-card-wide {
  grid-column: span 2;
}

.chart-canvas-wrap {
  position: relative;
  height: 220px;
}

.chart-canvas-tall {
  height: 300px;
}

.chart-canvas-compact {
  height: 200px;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

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

  .chart-card-wide {
    grid-column: span 1;
  }

  .chart-canvas-compact {
    max-width: none;
  }
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-span2 {
  grid-column: span 2;
}

@media (max-width: 720px) {
  .field-span2 {
    grid-column: span 1;
  }
}

.report-actions-top {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.report-meta {
  margin: 16px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 900px) {
  .menu-toggle {
    display: grid;
    place-items: center;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.12);
    z-index: 45;
  }

  .sidebar.is-open,
  body.drawer-open .sidebar {
    transform: translateX(0);
  }

  body.drawer-open .sidebar-backdrop.is-visible {
    display: block;
  }

  .shell {
    width: 100%;
  }

  .main {
    padding: 16px 14px 40px;
  }
}

.day-groups {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day-cluster {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  background: var(--transo-gray-50);
}

.day-cluster-sum {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  font-weight: 600;
}

.day-cluster-sum::-webkit-details-marker {
  display: none;
}

.day-cluster-body {
  padding: 0 0 12px;
  border-top: 1px solid var(--border);
}

.day-cluster-row {
  font-size: 0.85rem;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  color: var(--text);
}

.day-cluster-row:last-of-type {
  border-bottom: none;
}

  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-head-stack .panel-hint {
  display: block;
  margin-top: 4px;
}

.field-block {
  margin: 0 0 18px;
  max-width: 520px;
}

.field-hint {
  margin: -2px 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

.field-hint code {
  font-size: 0.82rem;
}

.input-control {
  width: 100%;
  max-width: 520px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.95rem;
}

.input-control:focus {
  outline: none;
  border-color: var(--transo-red);
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.12);
}

.pairing-actions {
  margin: 0 0 10px;
}

.pairing-meta {
  margin: 0 0 16px;
  font-size: 0.89rem;
  line-height: 1.45;
}

.pairing-callout {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.pairing-callout.is-hidden {
  display: none !important;
}

.pairing-callout--warn {
  background: #fff8e1;
  border-color: #ffe082;
  color: #6d4c41;
}

.pairing-callout--err {
  background: var(--transo-red-soft);
  border-color: #ffcdd2;
  color: var(--transo-red-dark);
}

.pairing-callout--info {
  background: #e8f5e9;
  border-color: #c8e6c9;
  color: #2e7d32;
}

.qr-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: clamp(18px, 3vw, 32px);
  align-items: start;
}

.qr-layout.qr-layout--single {
  grid-template-columns: 1fr;
  max-width: 320px;
}

.qr-layout.qr-layout--single .qr-well {
  justify-self: stretch;
}

.qr-well {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  justify-self: start;
}

.qr-well canvas,
.qr-well img {
  display: block;
  max-width: 100%;
  height: auto;
}

.qr-side {
  padding-top: 4px;
  font-size: 0.88rem;
}

.pairing-tips {
  margin: 8px 0 0;
  padding-left: 1.1rem;
}

.pairing-tips li {
  margin-bottom: 6px;
}

.devices-panel-pairing {
  margin-bottom: 0;
}

.devices-table th,
.devices-table td {
  font-size: 0.89rem;
}

.devices-td-id {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  max-width: 220px;
  overflow-wrap: anywhere;
}

.devices-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 6px 10px;
}

.btn-danger-ghost {
  color: var(--transo-red-dark);
  border-color: rgba(183, 28, 28, 0.45);
}

@media (max-width: 720px) {
  .qr-layout {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .qr-well {
    justify-self: center;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .field-block,
  .input-control {
    max-width: none;
  }
}

/* Utility + dashboard loading overlay */
.is-hidden {
  display: none !important;
}

.dash-load-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(18, 18, 18, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.dash-load-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px 28px;
  min-width: min(320px, 100%);
  max-width: 400px;
  border: 1px solid var(--border);
}

.dash-load-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 14px;
  border: 3px solid var(--transo-gray-200);
  border-top-color: var(--transo-red);
  border-radius: 50%;
  animation: dash-spin 0.75s linear infinite;
}

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

.dash-load-label {
  margin: 0 0 14px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text);
}

.dash-load-track {
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
}

.dash-load-progress {
  display: block;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  border: none;
  background: var(--transo-gray-200);
  appearance: none;
  -webkit-appearance: none;
  vertical-align: middle;
}

.dash-load-progress::-webkit-progress-bar {
  background: var(--transo-gray-200);
  border-radius: 999px;
}

.dash-load-progress::-webkit-progress-value {
  background: var(--transo-red);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.dash-load-progress::-moz-progress-bar {
  background: var(--transo-red);
  border-radius: 999px;
}

.dash-load-progress:indeterminate::-moz-progress-bar {
  background: linear-gradient(90deg, var(--transo-red-soft), var(--transo-red), var(--transo-red-soft));
  background-size: 200% auto;
  animation: dash-indet 1.1s ease-in-out infinite;
}

.dash-load-progress:indeterminate::-webkit-progress-value {
  background: var(--transo-red);
}

@keyframes dash-indet {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(380%);
  }
}

/* ---- Transo Assistant (full-page chat) ---- */
.assistant-page .assistant-shell {
  min-height: 100vh;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.assistant-page .assistant-chat-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
}

.assistant-intro {
  flex-shrink: 0;
}

.assistant-lead {
  margin-top: 0;
  max-width: 720px;
}

.assistant-suggestions {
  flex-shrink: 0;
}

.assistant-messages {
  flex: 1;
  min-height: 0;
}

.assistant-compose-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 -6px 24px rgba(18, 18, 18, 0.06);
}

.assistant-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.assistant-attach-btn {
  flex-shrink: 0;
  align-self: flex-end;
  border-radius: 14px;
  min-height: 44px;
}

.assistant-attach-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 0;
}

.assistant-thumb-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--transo-gray-50);
}

.assistant-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.assistant-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}

.assistant-msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.assistant-msg-img {
  max-width: min(200px, 100%);
  max-height: 160px;
  border-radius: 10px;
  object-fit: contain;
  border: 1px solid var(--border);
}

.ai-chat-suggestions {
  flex-shrink: 0;
  padding: 12px 14px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #faf7ff 0%, var(--surface) 100%);
}

.ai-suggestion-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font);
}

.ai-suggestion-chip:hover {
  border-color: #7c4dff;
  color: #5e35b1;
}

.ai-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 100%;
}

.ai-msg-user {
  flex-direction: row-reverse;
}

.ai-msg-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 0.62rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--transo-gray-600);
}

.ai-msg-user .ai-msg-avatar {
  background: var(--transo-red);
}

.ai-msg-assistant .ai-msg-avatar {
  background: linear-gradient(135deg, #7c4dff, #448aff);
}

.ai-msg-bubble {
  flex: 1;
  min-width: 0;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  background: var(--transo-gray-50);
  border: 1px solid var(--border);
}

.ai-msg-user .ai-msg-bubble {
  background: var(--transo-red-soft);
  border-color: #ffcdd2;
}

.ai-md-p {
  margin: 0 0 0.5rem;
}
.ai-md-p:last-child {
  margin-bottom: 0;
}
.ai-md-list {
  margin: 0.25rem 0 0.5rem 1rem;
  padding: 0;
}
.ai-md-list li {
  margin: 0.2rem 0;
}

.ai-artifact {
  margin-top: 10px;
  margin-left: 44px;
  max-width: calc(100% - 44px);
}

.ai-artifact-qr {
  padding: 12px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: #fff;
}

.ai-artifact-meta {
  font-size: 0.82rem;
  margin: 0 0 10px;
  line-height: 1.45;
}

.ai-artifact-meta code {
  font-size: 0.85em;
  background: var(--transo-gray-50);
  padding: 2px 6px;
  border-radius: 6px;
}

.ai-artifact-warn {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: #b71c1c;
}

.ai-qr-host {
  display: flex;
  justify-content: center;
}

.ai-qr-host img {
  display: block;
  border-radius: 8px;
}

.ai-msg-pending .ai-msg-bubble {
  padding: 14px;
}

.ai-typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--transo-gray-600);
  animation: ai-bounce 1s ease-in-out infinite;
}

.ai-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.ai-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ai-bounce {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.ai-chat-compose {
  flex-shrink: 0;
  padding: 12px 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.ai-chat-hint {
  margin: 0 0 8px;
  font-size: 0.72rem;
  min-height: 1em;
}

.ai-chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.ai-chat-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 0.9rem;
  line-height: 1.35;
  background: var(--transo-gray-50);
}

.ai-chat-input:focus {
  outline: 2px solid rgba(124, 77, 255, 0.35);
  outline-offset: 1px;
  border-color: #7c4dff;
  background: #fff;
}

.ai-chat-send {
  flex-shrink: 0;
  border-radius: 14px;
  padding-left: 18px;
  padding-right: 18px;
  min-height: 44px;
}
