:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --ink: #18211e;
  --muted: #69746f;
  --line: #d8ded8;
  --panel: #ffffff;
  --green: #7ca982;
  --green-weak: #dcebd8;
  --blue: #6f8fb8;
  --blue-weak: #dfe9f4;
  --yellow: #f1c75b;
  --red: #d85a54;
  --teal: #42a7a8;
  --shadow: 0 14px 30px rgba(26, 41, 34, 0.08);
}

* {
  box-sizing: border-box;
}

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

html.booting .app {
  visibility: hidden;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(247, 248, 244, 0.96);
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
}

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

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.small {
  padding: 7px 10px;
}

.tiny {
  padding: 5px 7px;
  font-size: 12px;
}

.app {
  min-height: 100vh;
  width: 100vw;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: #17221f;
  color: #f8fbf6;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-block .eyebrow {
  margin-bottom: 6px;
}

.brand-block h1 {
  font-size: 34px;
  line-height: 0.95;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0;
  color: var(--teal);
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  font-size: 30px;
}

h3 {
  font-size: 18px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  background: transparent;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #dfe7e1;
}

.nav-button.active {
  background: #e9f0de;
  color: #17221f;
}

.sync-panel {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 14px;
}

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

.sync-panel .label {
  color: #b6c4bc;
  margin: 0 0 10px;
}

.sync-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
}

.sync-row strong {
  color: var(--yellow);
}

main {
  padding: 26px;
  min-width: 0;
  max-width: calc(100vw - 260px);
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-gutter: stable;
}

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

.actions,
.filters,
.panel-head,
.command-row,
menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

.compact-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.language-switcher {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f6;
  padding: 3px;
}

.language-option {
  min-width: 42px;
  padding: 7px 10px;
  background: transparent;
  color: var(--ink);
}

.language-option.active {
  background: var(--ink);
  color: #fff;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff8dd;
  color: #735b13;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.success {
  background: #e9f0de;
  color: #315f38;
}

.status-pill.workflow-draft { background: #e6edf5; color: #34516c; }
.status-pill.workflow-review { background: #fff2d9; color: #785512; }
.status-pill.workflow-approved { background: #e7f1df; color: #35613d; }
.status-pill.workflow-posted { background: #dfeee4; color: #225b38; }
.status-pill.workflow-reversed { background: #f4e5e4; color: #8b322d; }
.status-pill.workflow-rejected { background: #f7e5e2; color: #96372e; }

.workflow-transition {
  max-width: 150px;
}

.workflow-overview {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin: 4px 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf7;
}

.workflow-steps,
.workflow-authority {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.workflow-authority {
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
}

.workflow-arrow {
  color: var(--muted);
  font-weight: 800;
}

.view {
  display: none;
}

.view.active {
  display: block;
  min-width: 1080px;
}

.hidden {
  display: none !important;
}

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

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

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

.collapsible-grid {
  overflow: hidden;
  transition: max-height 180ms ease, opacity 180ms ease, margin-bottom 180ms ease;
  max-height: 620px;
}

.collapsible-grid.collapsed {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  pointer-events: none;
}

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

.metric {
  min-height: 132px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metric span,
th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  font-size: 29px;
  line-height: 1;
}

.metric small {
  color: var(--muted);
}

.metric.risk {
  background: #fff8dd;
}

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

.nav-setup-panel {
  margin-bottom: 16px;
}

.nav-setup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.nav-setup-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.nav-setup-grid input {
  width: 100%;
}

.integration-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.nav-query-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.invoice-query-grid {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.taxpayer-query-grid {
  grid-template-columns: minmax(240px, 520px);
}

.nav-query-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.nav-invoice-results {
  margin-top: 12px;
}

.panel {
  padding: 16px;
  margin-bottom: 16px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
}

.summary {
  display: grid;
  gap: 10px;
  line-height: 1.45;
}

.summary p {
  margin: 0;
}

.action-list,
.rule-list,
.balance-grid,
.review-list,
.backend-log,
.statement-preview {
  display: grid;
  gap: 10px;
}

.action-item,
.rule-card,
.balance-card,
.review-card,
.log-line,
.statement-row {
  display: grid;
  gap: 6px;
  padding: 12px;
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.review-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.review-card small,
.log-line small {
  color: var(--muted);
}

.log-line {
  grid-template-columns: 90px minmax(0, 1fr);
  align-items: center;
}

.log-line.success strong {
  color: #315f38;
}

.log-line.error strong {
  color: #7c2722;
}

.statement-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.statement-row.total {
  background: #e9f0de;
  border-color: #b7d2b1;
}

.statement-panel {
  overflow: hidden;
}

.accounting-tabs {
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
  margin: 0 0 16px;
}

.accounting-tab {
  background: transparent;
  color: var(--ink);
  white-space: nowrap;
}

.accounting-tab.active {
  background: var(--ink);
  color: #fff;
}

.accounting-tab-panel {
  display: none;
}

.accounting-tab-panel.active {
  display: grid;
  gap: 16px;
}

.period-close-form {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(150px, 0.7fr) minmax(220px, 1.6fr) auto;
  align-items: end;
  gap: 12px;
}

.period-close-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.period-close-form button {
  white-space: nowrap;
}

.period-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.period-table {
  min-width: 900px;
}

.period-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--blue-weak);
  border-bottom: 2px solid var(--ink);
}

.period-table th,
.period-table td {
  padding: 10px 12px;
  vertical-align: middle;
}

.empty-table {
  color: var(--muted);
  text-align: center;
}

.statement-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.statement-type {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.statement-type.active {
  background: var(--ink);
  color: #fff;
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.statement-table {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.statement-table-head,
.statement-table-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 120px;
  align-items: center;
  gap: 12px;
}

.statement-table-head {
  background: #dfe9f4;
  color: var(--ink);
  font-weight: 800;
  padding: 10px 12px;
  border-bottom: 2px solid var(--ink);
}

.statement-table-row {
  min-height: 42px;
  padding: 9px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.statement-table-row:last-child {
  border-bottom: 0;
}

.statement-table-row.total {
  background: #eef4e8;
  font-weight: 800;
}

.statement-table-row.sources {
  border-top: 2px solid var(--line);
}

.statement-table-row strong,
.statement-table-head span:last-child {
  text-align: right;
}

.statement-table-row .negative {
  color: #7c2722;
}

.statement-table-row .positive {
  color: #315f38;
}

.advanced-panel {
  overflow: hidden;
}

.manual-entry-panel {
  overflow: hidden;
}

.manual-entry-panel .segmented {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.manual-type {
  background: transparent;
  color: var(--ink);
}

.manual-type.active {
  background: var(--ink);
  color: #fff;
}

.manual-entry-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.manual-entry-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.manual-entry-grid input,
.manual-entry-grid select {
  width: 100%;
}

.controls-panel {
  overflow: hidden;
}

.controls-catalogue {
  display: grid;
  gap: 18px;
  margin-top: 14px;
}

.control-priority {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.control-priority:first-child {
  border-top: 0;
  padding-top: 0;
}

.control-priority-head {
  align-items: center;
  display: flex;
  gap: 12px;
}

.control-priority-head p {
  color: var(--muted);
  font-weight: 700;
  margin: 0;
}

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

.control-column {
  display: grid;
  gap: 10px;
}

.control-column h4 {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0;
  margin: 0;
}

.control-card {
  align-items: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.control-card strong {
  display: block;
  margin-bottom: 5px;
}

.control-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin: 0;
}

.control-high {
  background: #fde2e2;
  color: #812020;
}

.control-medium {
  background: #fff1cc;
  color: #765200;
}

.control-low {
  background: #e9f4e4;
  color: #2b6038;
}

.ai-control {
  background: #dfeeff;
  color: #254b72;
  flex: 0 0 auto;
}

.manual-balance {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #b7d2b1;
  border-radius: 8px;
  background: var(--green-weak);
  color: #315f38;
}

.manual-balance.negative {
  border-color: #e4aaa4;
  background: #fff1ef;
  color: #7c2722;
}

.manual-result {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.advanced-filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(9, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.advanced-filters label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.advanced-filters input,
.advanced-filters select {
  width: 100%;
}

.advanced-summary {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.advanced-summary strong {
  color: var(--ink);
}

.list-pagination {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.list-pagination span {
  color: var(--muted);
  font-size: 13px;
}

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

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

.account-table {
  min-width: 980px;
}

.account-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--blue-weak);
  border-bottom: 2px solid var(--ink);
}

.account-table input,
.account-table select {
  width: 100%;
  min-width: 110px;
}

.account-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.accounting-conversion {
  display: grid;
  gap: 6px;
  grid-template-columns: 72px 104px max-content;
  min-width: 290px;
}

.accounting-conversion input,
.accounting-conversion select {
  min-width: 0;
  width: 100%;
}

.advanced-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1500px;
}

.advanced-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--blue-weak);
  border-bottom: 2px solid var(--ink);
}

.advanced-table th,
.advanced-table td {
  padding: 8px 10px;
  font-size: 13px;
  vertical-align: top;
}

.advanced-table tbody tr:hover td {
  background: #f8faf7;
}

.row-actions {
  white-space: nowrap;
}

.row-actions button + button {
  margin-left: 6px;
}

.strings-panel {
  overflow: hidden;
}

.strings-table {
  min-width: 920px;
}

.strings-table th:first-child,
.strings-table td:first-child {
  width: 240px;
}

.strings-table input {
  width: 100%;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.truncate {
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.rule-card input[data-rule-field="name"] {
  flex: 1;
  font-weight: 800;
}

.rule-amount {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 96px;
  gap: 8px;
  width: min(320px, 100%);
}

.rule-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--blue-weak);
  color: #274664;
  font-size: 12px;
  font-weight: 800;
}

.pill.cost {
  background: #ffe1dc;
  color: #7c2722;
}

.pill.paid {
  background: var(--green-weak);
  color: #315f38;
}

.pill.to_invoice,
.pill.deferred {
  background: #fff0b8;
  color: #775b00;
}

.bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 120px;
  gap: 12px;
  align-items: center;
}

.bar-track {
  min-height: 24px;
  border-radius: 6px;
  background: #edf1ec;
  overflow: hidden;
}

.bar-fill {
  height: 24px;
  width: var(--width);
  background: var(--green);
}

.bar-fill.cost {
  background: var(--red);
}

.segmented {
  border: 1px solid var(--line);
  padding: 3px;
  border-radius: 8px;
  background: #f7f9f6;
}

.segment {
  background: transparent;
  color: var(--ink);
  padding: 7px 12px;
}

.segment.active {
  background: var(--ink);
  color: #fff;
}

select,
input {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 7px;
  padding: 9px 10px;
  min-width: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  vertical-align: middle;
}

td input,
td select {
  width: 100%;
  padding: 7px 8px;
}

.right {
  text-align: right;
}

.delete-btn {
  background: transparent;
  color: var(--red);
  border: 1px solid #f0c4bf;
  padding: 6px 8px;
}

.cashflow-switcher {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px;
  margin-bottom: 14px;
}

.cashflow-mode {
  background: transparent;
  color: var(--ink);
  padding: 7px 12px;
}

.cashflow-mode.active {
  background: var(--ink);
  color: #fff;
}

.cashflow-board-panel {
  margin-bottom: 16px;
}

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

.month-picker,
.board-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.cashflow-month-compare {
  flex-wrap: wrap;
}

.month-selector {
  display: inline-flex;
  gap: 8px;
}

.month-selector select {
  min-width: 116px;
}

.month-selector select:first-child {
  min-width: 86px;
}

.compare-separator {
  color: var(--muted);
  font-weight: 800;
}

.board-legend {
  flex-wrap: wrap;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 5px;
}

.cost-dot {
  background: #ffe1dc;
  border: 1px solid #e4aaa4;
}

.income-dot {
  background: var(--green-weak);
  border: 1px solid #b7d2b1;
}

.muted-dot {
  background: #e5e7e3;
  border: 1px solid #ced5ce;
}

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

.month-board {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.month-board-head,
.sheet-header,
.sheet-row,
.month-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.month-board-head {
  background: #e9f0de;
  border-bottom: 2px solid #18211e;
  align-items: center;
  padding: 12px;
}

.month-board-head strong {
  font-size: 20px;
}

.month-board-head span {
  justify-self: end;
  font-weight: 800;
}

.sheet-header {
  background: #f7f9f6;
  border-bottom: 1px solid var(--line);
}

.sheet-header span {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.sheet-grid {
  display: grid;
}

.sheet-row {
  min-height: 50px;
}

.sheet-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 3px 10px;
  align-items: center;
  min-height: 50px;
  width: 100%;
  border-radius: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
}

.sheet-cell.income {
  background: var(--green-weak);
}

.sheet-cell.cost {
  background: #fff1ef;
}

.sheet-cell.to-invoice,
.sheet-cell.deferred {
  background: #fff700;
}

.sheet-cell.invoiced {
  background: var(--blue-weak);
}

.sheet-cell.past-due {
  background: #fff3d6;
  box-shadow: inset 4px 0 0 #cf7a18;
}

.sheet-cell.past-due small,
.pill.past-due {
  color: #8b4a0b;
  font-weight: 900;
}

.sheet-cell.excluded {
  background: #ecefec;
  color: #7b817d;
}

.sheet-cell.empty {
  min-height: 50px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.paid-section {
  background: #f4f6f3;
  border-bottom: 2px solid #18211e;
}

.paid-section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.paid-section-title strong,
.paid-section-title span {
  font-weight: 900;
}

.paid-list {
  display: grid;
}

.paid-sheet-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  align-items: center;
  width: 100%;
  border-radius: 0;
  border-top: 1px solid var(--line);
  background: #eef2ec;
  color: var(--muted);
  padding: 8px 12px;
  text-align: left;
}

.paid-sheet-item strong {
  color: var(--ink);
}

.paid-sheet-item .board-amount-stack {
  grid-row: 1 / span 2;
  grid-column: 2;
  justify-self: end;
}

.paid-sheet-item small {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.sheet-desc {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.sheet-cell strong {
  white-space: nowrap;
}

.sheet-cell .board-amount-stack {
  justify-self: end;
}

.board-amount-stack {
  display: grid;
  justify-items: end;
  line-height: 1.05;
  white-space: nowrap;
}

.board-main-amount {
  color: var(--ink);
}

.original-currency {
  grid-column: auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: none;
}

.sheet-cell small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.month-summary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 2px solid #18211e;
  background: #f8faf7;
}

.month-summary div {
  display: grid;
  gap: 4px;
  padding: 11px 10px;
  border-right: 1px solid var(--line);
}

.month-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.month-summary strong {
  font-size: 15px;
  white-space: nowrap;
}

.month-summary .positive strong {
  color: #276635;
}

.month-summary .negative strong {
  color: #a22d27;
}

.month-summary .closing {
  background: #e9f0de;
}

.balance-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.balance-card input {
  width: 100%;
}

.fx-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 240px));
  gap: 12px;
}

.fx-grid label,
.form-grid label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
}

.partner-master {
  align-items: start;
}

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

.partner-table {
  min-width: 980px;
}

.partner-table th,
.partner-table td {
  vertical-align: middle;
}

.partner-table input {
  width: 100%;
  min-width: 120px;
  padding: 7px 8px;
}

.partner-table .source-list {
  display: inline-block;
  min-width: 96px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.delete-btn:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.chat-log {
  min-height: 330px;
  max-height: 50vh;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.message {
  max-width: 760px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.message.user {
  justify-self: end;
  background: #e8f2ff;
}

.command-row {
  margin-top: 12px;
}

.command-row input {
  flex: 1;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 720px;
  width: calc(100vw - 32px);
}

dialog::backdrop {
  background: rgba(20, 30, 26, 0.3);
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-check {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: fit-content;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-check input {
  width: auto;
  margin: 0;
}

menu {
  justify-content: flex-end;
  padding: 0;
}

@media (max-width: 1050px) {
  .app {
    grid-template-columns: 1fr;
    width: 100%;
  }

  main {
    max-width: 100vw;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  nav {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .metric-grid,
  .two-column,
  .cashflow-board,
  .balance-grid,
  .control-grid,
  .advanced-filters,
  .manual-entry-grid,
  .period-close-form {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 700px) {
  main {
    padding: 16px;
  }

  .topbar,
  .actions,
  .panel-head,
  .cashflow-switcher,
  .board-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .month-selector {
    display: grid;
    grid-template-columns: minmax(84px, 0.7fr) minmax(0, 1fr);
  }

  nav,
  .metric-grid,
  .two-column,
  .cashflow-board,
  .balance-grid,
  .control-grid,
  .fx-grid,
  .form-grid,
  .advanced-filters,
  .manual-entry-grid,
  .period-close-form {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }
}
