:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #182026;
  --muted: #65717c;
  --line: #dbe2e7;
  --accent: #1f7a6d;
  --accent-2: #255f8f;
  --vfr-accent: #1f7a6d;
  --vfr-map-accent: #255f8f;
  --vfr-text-size: 14px;
  --vfr-title-size: 20px;
  --warn: #b25f00;
  --bad: #a33232;
  --shadow: 0 12px 36px rgba(24, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 40px;
}

button:hover {
  filter: brightness(0.96);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.app {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

p,
label,
.muted {
  color: var(--muted);
  font-size: 14px;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--muted);
  white-space: nowrap;
}

.status-pill.ok {
  color: var(--accent);
  border-color: rgba(31, 122, 109, 0.35);
}

.status-pill.bad {
  color: var(--bad);
  border-color: rgba(163, 50, 50, 0.35);
}

.area-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 12px;
  margin-bottom: 6px;
}

.area-tab {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  min-width: 190px;
  font-weight: 750;
}

.area-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.workspace-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.section-sidebar {
  position: sticky;
  top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 10px;
}

.sidebar-title {
  padding: 4px 6px 10px;
  font-weight: 800;
  color: var(--ink);
}

.page-nav {
  display: grid;
  gap: 7px;
}

.nav-tab {
  width: 100%;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  white-space: nowrap;
  text-align: left;
  padding: 10px 11px;
}

.nav-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head select {
  max-width: 220px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.chat-panel {
  min-height: 570px;
  display: flex;
  flex-direction: column;
}

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  overflow: auto;
  min-height: 390px;
  max-height: 58vh;
}

.message {
  width: min(760px, 92%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.message.user {
  align-self: flex-end;
  background: #eef6f4;
}

.message.assistant {
  align-self: flex-start;
  background: #f8fafb;
}

.llm-chat-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 145px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

.llm-chat-sidebar {
  border-right: 1px solid var(--line);
  background: #f8fafb;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.llm-chat-sidebar-head,
.llm-chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.llm-chat-sidebar-head button,
.llm-chat-tools button {
  min-height: 34px;
  padding: 7px 10px;
}

.llm-chat-list {
  display: grid;
  gap: 6px;
  padding: 10px;
  overflow: auto;
}

.llm-chat-history-item {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 0;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 10px;
}

.llm-chat-history-item.active,
.llm-chat-history-item:hover {
  border-color: var(--line);
  background: #fff;
}

.llm-chat-history-item strong,
.llm-chat-history-item span,
.llm-chat-history-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.llm-chat-history-item span,
.llm-chat-history-item small,
.llm-chat-meta,
.llm-chat-empty {
  color: var(--muted);
  font-size: 12px;
}

.llm-chat-main {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #fff;
}

.llm-chat-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.llm-chat-tools select {
  max-width: 220px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.llm-chat-messages {
  overflow: auto;
  padding: 24px clamp(14px, 4vw, 56px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.llm-chat-message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  max-width: 880px;
  width: 100%;
}

.llm-chat-message.user {
  align-self: flex-end;
}

.llm-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: #e7efed;
  color: var(--accent);
}

.llm-chat-message.user .llm-chat-avatar {
  background: #e7eef5;
  color: var(--accent-2);
}

.llm-chat-bubble {
  white-space: pre-wrap;
  line-height: 1.55;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: #f8fafb;
}

.llm-chat-message.user .llm-chat-bubble {
  background: #eef6f4;
}

.llm-chat-meta {
  margin-top: 6px;
}

.llm-chat-welcome {
  align-self: center;
  width: min(620px, 100%);
  margin: auto 0;
  text-align: center;
  display: grid;
  gap: 8px;
}

.llm-chat-welcome h3 {
  font-size: 24px;
  margin: 0;
}

.llm-chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.llm-chat-composer textarea {
  width: 100%;
  resize: vertical;
  max-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.composer textarea,
.searchbar input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
}

.composer textarea:focus,
.searchbar input:focus {
  border-color: rgba(31, 122, 109, 0.65);
  box-shadow: 0 0 0 3px rgba(31, 122, 109, 0.12);
}

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 20px;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 78px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metrics strong {
  font-size: 22px;
}

.actions {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.actions button:nth-child(2) {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.actions button:nth-child(3) {
  background: var(--warn);
  border-color: var(--warn);
}

.action-log {
  min-height: 38px;
  padding: 0 14px 14px;
}

.search-panel,
.accounting-panel,
.voice-panel,
.customer-panel,
.supplier-panel,
.module-panel {
  margin-top: 0;
}

.voice-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  align-items: stretch;
}

.voice-state {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  white-space: nowrap;
}

.record-button {
  min-height: 124px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 700;
  background: #1f7a6d;
  touch-action: manipulation;
  user-select: none;
}

.record-button.recording {
  background: #a33232;
  border-color: #a33232;
}

.voice-log {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.voice-log div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 96px;
  background: #fbfcfd;
}

.voice-log span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.voice-log strong {
  display: block;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 600;
  white-space: pre-wrap;
}

.voice-log audio {
  grid-column: 1 / -1;
  width: 100%;
}

.toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.searchbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 10px;
  padding: 14px;
}

.results {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.result {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.result strong {
  display: block;
  margin-bottom: 5px;
  overflow-wrap: anywhere;
}

.result .meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.download {
  color: var(--accent-2);
  text-decoration: none;
  border: 1px solid rgba(37, 95, 143, 0.35);
  border-radius: 6px;
  padding: 8px 10px;
  white-space: nowrap;
}

.periodbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 220px)) 120px 110px 110px 130px;
  gap: 10px;
  padding: 14px;
  align-items: end;
}

.periodbar label {
  display: grid;
  gap: 5px;
}

.periodbar input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 180px)) minmax(240px, 1fr) 220px 120px;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  align-items: end;
}

.toolbar input,
.toolbar select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  min-width: 0;
}

.toolbar label {
  display: grid;
  gap: 5px;
}

.finance-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 0 14px 14px;
}

.finance-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 82px;
  background: #fbfcfd;
}

.finance-metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.finance-metrics strong {
  font-size: 19px;
  overflow-wrap: anywhere;
}

.accounting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 14px 14px;
}

.relation-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
  padding: 0 14px 14px;
}

.customer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.55fr);
  gap: 14px;
  padding: 14px;
}

.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
  min-height: 240px;
}

.detail-panel h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.detail-panel h4 {
  margin: 12px 0 8px;
  font-size: 14px;
}

.detail-content {
  display: grid;
  gap: 10px;
}

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

.detail-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.detail-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.row-button {
  border: 0;
  background: transparent;
  color: var(--accent-2);
  min-height: 0;
  padding: 0;
  text-align: left;
}

.invoice-section,
.category-section {
  padding: 0 14px 14px;
}

.accounting-grid h3,
.relation-grid h3,
.invoice-section h3,
.category-section h3 {
  font-size: 16px;
  margin: 0 0 8px;
}

.data-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  max-height: 420px;
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #eef3f5;
  z-index: 1;
}

.data-table td.num,
.data-table th.num {
  text-align: right;
}

.data-table .name {
  white-space: normal;
  min-width: 180px;
}

.mode-badge {
  border: 1px solid rgba(178, 95, 0, 0.35);
  color: var(--warn);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 13px;
  white-space: nowrap;
}

.module-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px;
}

.module-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
  min-width: 0;
}

.module-box-wide {
  grid-column: 1 / -1;
}

.module-box h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.module-box h4 {
  margin: 12px 0 8px;
  font-size: 14px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.inline-form label,
.stack-form {
  display: grid;
  gap: 6px;
}

.inline-form input,
.stack-form input,
.module-box textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  resize: vertical;
  background: #fff;
  min-width: 0;
}

.stack-form {
  gap: 10px;
  margin-bottom: 10px;
}

.module-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 10px 0;
}

.vfr-module-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.vfr-module-metrics small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.vfr-module-tables {
  margin-top: 12px;
}

.vfr-module-box .data-table {
  max-height: 360px;
  overflow: auto;
}

.check-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
}

.check-list ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.check-list li {
  margin: 4px 0;
  color: var(--muted);
}

.split-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.compact-results {
  padding: 0;
  max-height: 360px;
  overflow: auto;
}

.preview-box {
  margin: 10px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 260px;
  font-size: 12px;
}

.vfr-panel {
  font-size: var(--vfr-text-size);
}

.vfr-panel h3 {
  margin: 0;
  font-size: var(--vfr-title-size);
  letter-spacing: 0;
}

.vfr-head-actions,
.section-title-row,
.inline-mini-form {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.section-title-row {
  justify-content: space-between;
  margin-bottom: 10px;
}

.vfr-shell {
  padding: 14px;
}

.vfr-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.vfr-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
  min-height: 78px;
}

.vfr-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.vfr-metrics strong {
  font-size: 17px;
}

.vfr-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 14px;
  align-items: start;
}

.vfr-main-column,
.vfr-side-column {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.vfr-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
  min-width: 0;
}

.vfr-live-frame {
  width: 100%;
  min-height: 720px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.vfr-large-map {
  width: 100%;
  height: min(72vh, 720px);
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #eef3f5;
}

.vfr-route-info {
  margin-top: 8px;
}

.inline-mini-form {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline-mini-form input,
.inline-mini-form select,
.vfr-settings-form input,
.vfr-settings-form select,
.vfr-edit-form input,
.vfr-edit-form textarea,
.runway-row input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  min-width: 0;
}

.inline-mini-form input {
  width: 180px;
}

.vfr-settings-form,
.vfr-edit-form {
  display: grid;
  gap: 10px;
}

.vfr-settings-form label,
.vfr-edit-form label {
  display: grid;
  gap: 5px;
}

.vfr-settings-form .toggle,
.vfr-edit-form .toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vfr-settings-form input[type="color"] {
  height: 42px;
  padding: 4px;
}

.split-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.runway-editor {
  display: grid;
  gap: 8px;
}

.runway-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) 38px;
  gap: 6px;
}

.runway-row button {
  width: 38px;
  padding: 0;
  border-color: rgba(163, 50, 50, 0.35);
  background: #fff;
  color: var(--bad);
}

.vfr-airport-table {
  max-height: 620px;
}

.vfr-airport-table td {
  font-size: var(--vfr-text-size);
}

.vfr-airport-detail-row td {
  background: #fbfdfe;
  padding-top: 0;
  white-space: normal;
}

.vfr-airport-detail {
  display: grid;
  gap: 7px;
  padding: 4px 0 10px 118px;
  color: var(--muted);
}

.vfr-airport-detail > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vfr-airport-detail span {
  display: inline-flex;
  gap: 5px;
  max-width: 560px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff;
  white-space: normal;
}

.vfr-airport-detail b {
  color: var(--ink);
}

.vfr-airport-detail p {
  margin: 0;
  max-width: 1080px;
  color: var(--muted);
}

.vfr-airport-detail nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body[data-vfr-density="compact"] .vfr-airport-table td,
body[data-vfr-density="compact"] .vfr-airport-table th {
  padding: 5px 7px;
  font-size: 12px;
}

.vfr-panel button:not(.row-button) {
  border-color: var(--vfr-accent);
  background: var(--vfr-accent);
}

.vfr-panel .download {
  color: var(--vfr-map-accent);
}

.vfr-course-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.vfr-course-map {
  width: 100%;
  height: min(64vh, 620px);
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #eef3f5;
}

.vfr-course-summary {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.vfr-course-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.vfr-course-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.vfr-course-summary strong {
  font-size: 17px;
}

.bot-llm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.7fr);
  gap: 16px;
  align-items: start;
}

.bot-llm-grid .module-box-wide {
  grid-column: 1 / -1;
}

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

.bot-helper-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbfc;
  display: grid;
  gap: 10px;
}

.bot-helper-row label,
.bot-llm-settings-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.bot-helper-row input,
.bot-helper-row textarea,
.bot-llm-settings-form input,
.bot-llm-settings-form select,
#bot-examples-raw {
  width: 100%;
  border: 1px solid #cddce2;
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.bot-flow {
  display: grid;
  gap: 10px;
}

.bot-flow div {
  display: grid;
  grid-template-columns: 34px 1fr;
  column-gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fbfc;
}

.bot-flow span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--vfr-accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.bot-flow strong {
  color: var(--text);
}

.bot-flow p {
  grid-column: 2;
  margin: 2px 0 0;
  color: var(--muted);
}

.jobs-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.jobs-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #f8fafb;
}

.jobs-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.jobs-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.subagent-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.subagent-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #f8fafb;
}

.subagent-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.subagent-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.subagent-rule-board {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.subagent-rule-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.subagent-rule-head h3,
.subagent-rule-head p {
  margin: 0;
}

.subagent-rule-head p {
  color: var(--muted);
  margin-top: 4px;
}

.subagent-rule-counters,
.subagent-rule-status {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.subagent-rule-counters span,
.subagent-rule-status div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fafb;
}

.subagent-rule-status div {
  min-width: 150px;
}

.subagent-rule-status span,
.subagent-rule-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.subagent-rule-status strong {
  display: block;
  margin-top: 3px;
}

.subagent-rule-table {
  display: grid;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.subagent-rule-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.85fr) minmax(160px, 1fr) minmax(220px, 1.25fr) minmax(200px, 1.15fr) minmax(190px, 1fr) minmax(190px, 1fr) minmax(170px, 0.9fr);
  gap: 10px;
  width: 100%;
  min-height: 54px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.subagent-rule-row.head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.subagent-rule-row.active {
  background: #f3faf8;
}

.subagent-rule-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.platform-badge.telegram {
  border-color: rgba(37, 95, 143, 0.35);
  color: var(--accent-2);
}

.platform-badge.whatsapp {
  border-color: rgba(31, 122, 109, 0.35);
  color: var(--accent);
}

.subagent-avatar {
  display: block;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #f8fafb;
}

.subagent-avatar.large {
  width: 74px;
  height: 74px;
}

.subagent-workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(380px, 1.35fr);
  gap: 14px;
  padding: 14px;
}

.subagent-list {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: calc(100vh - 310px);
  overflow: auto;
  padding-right: 4px;
}

.subagent-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.subagent-card.active {
  border-color: var(--accent);
  background: #f3faf8;
}

.subagent-card strong,
.subagent-card small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subagent-card small {
  color: var(--muted);
  margin-top: 3px;
}

.subagent-card-meta {
  display: grid;
  justify-items: end;
  gap: 5px;
}

.subagent-detail {
  display: grid;
  gap: 12px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.subagent-detail-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.subagent-detail h3,
.subagent-detail p {
  margin: 0;
}

.subagent-detail small,
.subagent-detail p {
  color: var(--muted);
}

.subagent-detail label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.subagent-detail input,
.subagent-detail select,
.subagent-detail textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  resize: vertical;
}

.subagent-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.subagent-logbook {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

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

.subagent-section-head h4,
.subagent-section-head p {
  margin: 0;
}

.subagent-section-head p {
  color: var(--muted);
  font-size: 12px;
}

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

.subagent-log-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafb;
}

.subagent-log-list p {
  margin: 5px 0;
  color: var(--ink);
}

.subagent-log-list small {
  color: var(--muted);
}

.detail-empty {
  color: var(--muted);
}

.disposition-toolbar {
  grid-template-columns: minmax(240px, 1fr) 120px minmax(180px, 280px);
}

.disposition-results {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.disposition-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.disposition-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.disposition-card-head strong,
.disposition-card-head small,
.disposition-card-head span {
  display: block;
  overflow-wrap: anywhere;
}

.disposition-card-head small,
.disposition-card-head span {
  color: var(--muted);
  font-size: 12px;
}

.disposition-card h3 {
  margin: 0 0 4px;
  font-size: 13px;
}

.disposition-card p {
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.disposition-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.disposition-tags span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 8px;
}

.disposition-tags .tool {
  color: var(--accent-2);
  border-color: rgba(37, 95, 143, 0.35);
}

.data-table small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.jobs-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 14px 0;
}

.jobs-tab {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.jobs-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.jobs-content {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.job-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.job-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  border: 1px solid var(--line);
}

.job-pill.ok {
  color: var(--accent);
  border-color: rgba(31, 122, 109, 0.35);
  background: #eef6f4;
}

.job-pill.muted {
  color: var(--muted);
  background: #f4f6f7;
}

.job-command {
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.job-actions button,
.job-row > button {
  min-height: 34px;
  padding: 7px 10px;
}

.mini-preview {
  margin: 8px 0 0;
  max-width: min(620px, 72vw);
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 12px;
}

@media (max-width: 900px) {
  .app {
    padding: 12px;
  }

  .topbar,
  .workspace-layout,
  .grid,
  .result {
    display: block;
  }

  .section-sidebar {
    position: static;
    margin-bottom: 12px;
  }

  .llm-chat-shell {
    grid-template-columns: 1fr;
    min-height: 76vh;
  }

  .llm-chat-sidebar {
    max-height: 230px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .llm-chat-top,
  .llm-chat-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .llm-chat-tools select {
    max-width: none;
    width: 100%;
  }

  .page-nav {
    display: flex;
    overflow-x: auto;
  }

  .nav-tab {
    width: auto;
    text-align: center;
  }

  .side,
  .search-panel {
    margin-top: 12px;
  }

  .composer,
  .searchbar,
  .periodbar,
  .voice-body,
  .voice-log,
  .toolbar,
  .customer-layout,
  .subagent-workspace,
  .llm-chat-composer {
    grid-template-columns: 1fr;
  }

  .finance-metrics,
  .accounting-grid,
  .relation-grid,
  .jobs-summary,
  .subagent-summary,
  .job-row,
  .module-grid,
  .bot-llm-grid,
  .vfr-course-layout,
  .split-tables,
  .module-metrics,
  .inline-form,
  .vfr-metrics,
  .vfr-layout,
  .split-inputs,
  .runway-row {
    grid-template-columns: 1fr;
  }

  .section-title-row,
  .vfr-head-actions,
  .job-actions,
  .inline-mini-form {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-mini-form input,
  .inline-mini-form select {
    width: 100%;
  }

  .subagent-list {
    max-height: 340px;
  }

  .subagent-detail-head {
    grid-template-columns: 1fr;
  }

  .vfr-live-frame {
    min-height: 640px;
  }

  .vfr-large-map {
    height: 70vh;
    min-height: 430px;
  }

  .vfr-course-map {
    height: 64vh;
    min-height: 390px;
  }

  .download {
    display: inline-block;
    margin-top: 10px;
  }
}
