:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #18201d;
  --muted: #65716b;
  --line: #dfe5df;
  --line-strong: #c8d1c9;
  --accent: #1f7a6b;
  --accent-dark: #14564c;
  --accent-soft: #dff1ed;
  --warn: #b65f24;
  --danger: #b93c3c;
  --paid: #567d35;
  --scheduled: #426eb8;
  --shadow: 0 14px 35px rgba(26, 37, 32, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand,
.date-controls,
.actions,
.panel-title,
.dialog-head,
.dialog-actions,
.bill-card-head {
  display: flex;
  align-items: center;
}

.brand {
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
}

.brand-logo-button {
  display: block;
  width: 118px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  text-align: left;
}

.brand-logo {
  width: 118px;
  height: 118px;
  display: block;
  border-radius: 0;
  object-fit: contain;
  object-position: left top;
  background: transparent;
  border: 0;
  padding: 0;
}

.brand-product {
  display: grid;
  gap: 2px;
  line-height: 1.05;
}

.brand-product strong {
  color: var(--ink);
  font-size: 1.16rem;
}

.brand-product span {
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 800;
}

.brand p {
  font-size: 0.95rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 1.05rem;
}

p,
span,
.bill-meta,
.day-empty {
  color: var(--muted);
}

.summary-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.summary-strip > div,
.panel,
.details-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-strip > div {
  padding: 14px;
}

.summary-comparison {
  display: grid;
  gap: 10px;
}

.summary-comparison-head > span {
  color: var(--ink);
  font-weight: 800;
}

.summary-comparison-head > small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

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

.summary-pair > span {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 10px;
}

.summary-strip span,
.summary-strip strong,
.summary-pair > span {
  display: block;
}

.summary-strip strong {
  margin-top: 4px;
  font-size: 1.35rem;
}

.remaining-summary {
  background: #f7f9f6;
  border-style: dashed;
  box-shadow: none;
}

.remaining-summary .summary-comparison-head > span,
.remaining-summary strong {
  color: var(--muted);
}

.remaining-summary .summary-pair > span {
  background: #f9fbf8;
}

.panel {
  padding: 16px;
}

.panel-title {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-body {
  display: grid;
  gap: 12px;
}

.collapsible-panel.is-collapsed .panel-title {
  margin-bottom: 0;
}

.collapsible-panel.is-collapsed .panel-body {
  display: none;
}

.upcoming-list,
.day-list,
.list-items {
  display: grid;
  gap: 10px;
}

.workspace {
  min-width: 0;
  padding: 24px;
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  gap: 18px;
}

.display-segmented {
  width: min(260px, 100%);
}

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

.date-controls {
  gap: 10px;
}

.date-controls h2 {
  font-size: 1.7rem;
}

.actions {
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-start;
}

.view-control-stack {
  display: grid;
  gap: 8px;
  min-width: min(420px, 100%);
}

.period-segmented {
  width: 100%;
}

.period-action-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.period-action-row .period-segmented {
  flex: 1 1 auto;
}

.period-extra-select {
  width: 118px;
  min-height: 40px;
  padding: 0 10px;
}

.display-action-row {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
}

.segmented.display-segmented {
  flex: 1 1 220px;
  grid-template-columns: repeat(2, minmax(82px, 1fr));
  max-width: 260px;
}

.add-bill-compact {
  width: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segment {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 10px 14px;
  color: var(--muted);
}

.segment:last-child {
  border-right: 0;
}

.segment.is-active {
  background: var(--accent);
  color: white;
}

.primary-button,
.ghost-button,
.icon-button,
.danger-button,
.file-button {
  border-radius: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  padding: 0 14px;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.85rem;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

.file-button span {
  color: white;
}

.primary-button:hover,
.segment.is-active:hover,
.file-button:hover {
  background: var(--accent-dark);
}

.ghost-button,
.icon-button {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}

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

.danger-button {
  background: #fff5f5;
  color: var(--danger);
  border-color: #efc8c8;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-weight: 700;
  padding: 0;
  min-height: 0;
}

.negative-amount {
  color: var(--danger);
}

.calendar-section {
  min-width: 0;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.weekday-row div {
  padding: 0 8px 8px;
}

.calendar-grid {
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-height: 520px;
}

.day-cell {
  min-height: 120px;
  background: var(--surface);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-width: 0 1px 1px 0;
  cursor: pointer;
  text-align: left;
}

.week-grid .day-cell {
  min-height: 430px;
}

.biweekly-grid .day-cell {
  min-height: 220px;
}

.quarterly-grid .day-cell {
  min-height: 105px;
}

.yearly-grid .day-cell {
  min-height: 76px;
  padding: 8px;
  gap: 6px;
}

.day-grid {
  grid-template-columns: 1fr;
}

.day-grid .day-cell {
  min-height: 480px;
}

.day-cell.is-outside {
  background: #f1f3ef;
}

.day-cell.is-selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.day-number {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.day-select-button {
  min-width: 30px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-weight: 400;
  text-align: left;
}

.day-select-button:hover,
.day-select-button:focus-visible {
  background: #edf3ee;
}

.today-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.cell-add-button {
  width: 28px;
  height: 28px;
  margin-left: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #f9fbf8;
  color: var(--accent-dark);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}

.cell-add-button:hover,
.cell-add-button:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.bill-pill {
  border: 0;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  text-align: left;
  padding: 7px 8px;
  border-radius: 6px;
  display: grid;
  gap: 2px;
  min-width: 0;
  width: 100%;
}

.bill-pill:hover,
.bill-pill:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(31, 122, 107, 0.35);
}

.bill-pill strong,
.bill-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.bill-pill.paid {
  border-color: var(--paid);
  background: #e8f1df;
}

.bill-pill.paid strong,
.bill-pill.paid small,
.bill-card.paid h3,
.bill-card.paid .bill-amount,
.bill-card.paid .amount-value {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.bill-pill.scheduled {
  border-color: var(--scheduled);
  background: #e7eef9;
}

.bill-pill.income {
  border-color: #0c8f77;
  background: #e3f8f1;
}

.bill-pill.overdue {
  border-color: var(--danger);
  background: #fff0f0;
}

.transaction-pill {
  border: 0;
  border-left: 4px solid #6b7280;
  background: #f1f5f9;
  color: var(--ink);
  text-align: left;
  padding: 6px 8px;
  border-radius: 6px;
  display: grid;
  gap: 2px;
  min-width: 0;
  width: 100%;
}

.transaction-pill strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.transaction-pill.income {
  border-left-color: #0c8f77;
  background: #e3f8f1;
}

.transaction-pill.expense {
  border-left-color: #7c3aed;
  background: #f2edff;
}

.transaction-pill.transfer {
  border-left-color: #6b7280;
  background: #f1f5f9;
}

.transaction-pill.credit {
  border-left-color: #b65f24;
  background: #fff4df;
}

.transaction-pill.matched {
  border-left-color: var(--paid);
}

.transaction-pill.actual-summary .actual-title,
.list-item.actual-summary .actual-title,
.list-item.actual-summary .actual-amount em {
  font-style: italic;
  font-weight: 400;
}

.transaction-pill.actual-summary small {
  font-style: italic;
}

.transaction-pill.collapsed-actual {
  border-left-color: var(--muted);
  background: #f4f7f2;
  padding-block: 5px;
}

.transaction-pill.collapsed-actual .actual-title {
  font-size: 0.84rem;
}

.transaction-pill.collapsed-actual small {
  font-size: 0.74rem;
}

.more-count {
  color: var(--muted);
  font-size: 0.82rem;
}

.list-section {
  display: grid;
  align-content: start;
  gap: 12px;
}

.list-day-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.list-day-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.list-day-head h3 {
  margin: 0 0 3px;
}

.list-day-head span,
.list-day-totals {
  color: var(--muted);
  font-size: 0.9rem;
}

.list-day-totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 11px 12px;
  background: #f9fbf8;
  color: var(--ink);
  text-align: left;
}

.list-item-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.88rem;
}

.list-item-amount {
  display: grid;
  justify-items: end;
  gap: 2px;
  text-align: right;
}

.list-item-amount span,
.list-item-amount small {
  color: var(--muted);
}

.list-item-amount span {
  font-size: 0.74rem;
  font-weight: 700;
}

.list-item-amount strong {
  color: var(--ink);
  font-size: 1rem;
}

.list-item-amount em {
  color: var(--ink);
  font-size: 1rem;
}

.list-item-amount small {
  font-size: 0.78rem;
}

.amount-comparison {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 8px;
  width: 100%;
}

.amount-comparison.income {
  grid-template-columns: repeat(3, minmax(92px, 1fr));
}

.amount-cell {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  padding: 8px 10px;
}

.amount-label,
.amount-value {
  display: block;
}

.amount-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.amount-value {
  margin-top: 2px;
  font-size: 0.95rem;
}

.list-item.paid strong,
.list-item.paid .list-item-subtitle,
.list-item.paid .list-item-amount strong {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.list-item.income {
  border-left-color: #0c8f77;
  background: #e3f8f1;
}

.list-item.overdue {
  border-left-color: var(--danger);
}

.list-item.transaction {
  border-left-color: #7c3aed;
  background: #f7f3ff;
}

.list-item.transaction.income {
  border-left-color: #0c8f77;
  background: #e3f8f1;
}

.list-item.transaction.transfer {
  border-left-color: #6b7280;
  background: #f1f5f9;
}

.list-item.transaction.credit {
  border-left-color: #b65f24;
  background: #fff4df;
}

.details-panel {
  padding: 16px;
}

.bill-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fcfdfa;
}

.bill-card-head {
  justify-content: space-between;
  gap: 12px;
}

.bill-card h3 {
  margin: 0 0 3px;
  font-size: 1rem;
}

.bill-amount {
  font-weight: 800;
}

.bill-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.9rem;
  margin-top: 8px;
}

.bill-meta a {
  color: var(--accent-dark);
}

.bill-card .amount-comparison {
  margin-top: 10px;
}

.inline-link,
.pay-link {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration-thickness: 2px;
}

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

.is-hidden {
  display: none;
}

.status-chip {
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.8rem;
}

.bill-card.income .status-chip {
  background: #e3f8f1;
  color: #0c6557;
}

.transaction-card {
  border: 1px solid var(--line);
  border-left: 4px solid #7c3aed;
  border-radius: 8px;
  padding: 12px;
  background: #f7f3ff;
}

.transaction-card.income {
  border-left-color: #0c8f77;
  background: #e3f8f1;
}

.transaction-card.transfer {
  border-left-color: #6b7280;
  background: #f1f5f9;
}

.transaction-card.credit {
  border-left-color: #b65f24;
  background: #fff4df;
}

.transaction-card h3 {
  margin: 0 0 3px;
  font-size: 1rem;
}

.transaction-card strong {
  font-size: 1rem;
}

.csv-detail-section {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fcfdfa;
}

.csv-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.csv-detail-head h3 {
  margin: 0 0 3px;
  font-size: 1rem;
}

.csv-detail-head span,
.csv-detail-totals,
.csv-category-summary {
  color: var(--muted);
  font-size: 0.84rem;
}

.csv-detail-totals,
.csv-category-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.csv-category-summary {
  justify-content: flex-start;
}

.csv-category-summary em {
  color: var(--ink);
  font-style: italic;
}

.csv-detail-grid {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.csv-detail-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) minmax(92px, 1fr) minmax(82px, auto) minmax(74px, auto);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
}

.csv-detail-row:first-child {
  border-top: 0;
}

.csv-detail-header {
  background: #f4f7f2;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

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

.csv-detail-row span:nth-child(3),
.csv-detail-row span:nth-child(4) {
  text-align: right;
}

.csv-detail-row.expense span:nth-child(3) {
  color: var(--danger);
}

.csv-detail-row.income span:nth-child(3) {
  color: #0c6557;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-filter-block {
  display: grid;
  gap: 8px;
}

.field-caption {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.account-options {
  display: grid;
  gap: 8px;
}

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

.account-check-row input {
  width: auto;
}

.account-label {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.account-label strong {
  font-size: 0.92rem;
}

.account-label small {
  color: var(--muted);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-badge {
  display: grid;
  min-width: 58px;
  justify-items: end;
  gap: 1px;
  color: var(--muted);
  white-space: nowrap;
}

.account-badge strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.account-badge small,
.account-empty {
  color: var(--muted);
  font-size: 0.82rem;
}

.account-empty {
  margin: 0;
}

.sync-panel {
  display: grid;
  gap: 12px;
}

.sync-pill {
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef1ed;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.sync-pill[data-tone="online"] {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.sync-pill[data-tone="busy"] {
  background: #fff4df;
  color: var(--warn);
}

.sync-pill[data-tone="error"] {
  background: #fff0f0;
  color: var(--danger);
}

.sync-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sync-actions button {
  padding: 0 8px;
}

.sync-help {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.import-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.import-summary {
  color: var(--muted);
  font-size: 0.88rem;
}

.transaction-warning {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  border: 1px solid #e7c98f;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff8e8;
  color: #614511;
  font-size: 0.84rem;
}

.transaction-warning strong,
.transaction-warning p {
  margin: 0;
}

.transaction-warning p {
  line-height: 1.35;
}

#mappingDialog {
  width: min(980px, calc(100vw - 28px));
}

#formActualDialog {
  width: min(860px, calc(100vw - 28px));
}

#csvMappingDialog {
  width: min(920px, calc(100vw - 28px));
}

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

.csv-mapping-help {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  border: 1px solid #cdd8d0;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8faf6;
  color: var(--muted);
  font-size: 0.84rem;
}

.csv-mapping-help strong,
.csv-mapping-help p {
  margin: 0;
}

.csv-preview {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  background: #fcfdfa;
}

.csv-preview-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.csv-preview-title span {
  color: var(--muted);
  font-size: 0.82rem;
}

.csv-preview-table {
  min-width: 720px;
}

.csv-preview-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(120px, 1fr));
  border-bottom: 1px solid var(--line);
}

.csv-preview-row:last-child {
  border-bottom: 0;
}

.csv-preview-row span {
  min-width: 0;
  overflow: hidden;
  padding: 8px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.csv-preview-header {
  background: #eef3ed;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.mapping-summary-strip,
.mapping-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mapping-summary-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f9fbf8;
}

.mapping-summary-strip span,
.mapping-column-head span,
#mappingSummary {
  color: var(--muted);
  font-size: 0.84rem;
}

.mapper-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 0.45fr);
  gap: 10px;
  margin-top: 12px;
}

.compact-tools {
  grid-template-columns: minmax(0, 1fr);
  margin-top: 0;
}

.mapper-tools label {
  min-width: 0;
}

.mapper-tools input,
.mapper-tools select {
  min-height: 40px;
}

.mapping-board {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr);
  gap: 12px;
  margin-top: 14px;
}

.mapping-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.mapping-column .mapping-list {
  min-height: 260px;
  max-height: 50vh;
}

.mapping-column-head h3 {
  margin: 0;
  font-size: 1rem;
}

.mapping-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fcfdfa;
}

.form-actual-list {
  max-height: min(52vh, 520px);
  margin-top: 14px;
}

.mapping-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f9fbf8;
  color: var(--ink);
  text-align: left;
}

.mapping-item.transaction {
  grid-template-columns: 28px minmax(0, 1fr) auto;
}

.mapping-item.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mapping-item.is-mapped {
  box-shadow: inset 4px 0 0 var(--paid);
}

.mapping-item.is-mapped-elsewhere {
  box-shadow: inset 4px 0 0 var(--warn);
}

.mapping-main,
.mapping-amounts {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.mapping-main strong,
.mapping-main small,
.mapping-amounts span,
.mapping-amounts em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mapping-main small,
.mapping-amounts span,
.mapping-amounts em {
  color: var(--muted);
  font-size: 0.78rem;
}

.mapping-amounts {
  justify-items: end;
  text-align: right;
}

.mapping-check {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: white;
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 800;
}

.mapping-total {
  font-weight: 800;
  white-space: nowrap;
}

.mapping-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px;
  margin-top: 14px;
}

.analytics-reports {
  display: grid;
  gap: 12px;
}

.analytics-report {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.analytics-report:first-child {
  border-top: 0;
  padding-top: 0;
}

.analytics-report-head,
.analytics-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.analytics-report-head h3 {
  margin: 0 0 2px;
  font-size: 0.98rem;
}

.analytics-report-head span,
.analytics-row-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.analytics-report-body[hidden] {
  display: none;
}

.analytics-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.analytics-row {
  display: grid;
  gap: 5px;
}

.analytics-row-top strong {
  font-size: 0.92rem;
}

.analytics-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2ed;
}

.analytics-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.analytics-row.expense .analytics-bar span {
  background: var(--danger);
}

.analytics-row.expense .analytics-row-top span {
  color: var(--danger);
}

.analytics-row.income .analytics-row-top span {
  color: #0c6557;
}

.category-manager-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.category-row,
.category-add-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: end;
  gap: 8px;
}

.category-row input[disabled] {
  background: #f4f6f3;
  color: var(--muted);
}

.category-add-row {
  grid-template-columns: 1fr auto;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

dialog {
  width: min(780px, calc(100vw - 28px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(13, 20, 17, 0.28);
}

dialog::backdrop {
  background: rgba(11, 17, 14, 0.42);
}

form {
  padding: 22px;
}

.dialog-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

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

label {
  display: grid;
  gap: 6px;
}

label span {
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
}

input[readonly] {
  background: #f4f7f2;
  color: var(--muted);
}

textarea {
  resize: vertical;
}

.span-2 {
  grid-column: 1 / -1;
}

.dialog-actions {
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

.dialog-actions > div {
  display: flex;
  gap: 10px;
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .period-action-row {
    flex-direction: column;
  }

  .period-extra-select {
    width: 100%;
  }

  .view-control-stack {
    min-width: 0;
  }

  .display-action-row {
    justify-content: stretch;
  }

  .segmented.display-segmented {
    max-width: none;
  }

  .add-bill-compact {
    flex: 0 0 44px;
  }

  .date-controls {
    flex-wrap: wrap;
  }

  .segmented {
    width: 100%;
  }

  .display-segmented {
    width: auto;
  }

  .summary-strip,
  .form-grid,
  .amount-row,
  .mapper-tools,
  .csv-mapping-grid,
  .mapping-board,
  .mapping-actions {
    grid-template-columns: 1fr;
  }

  .mapping-summary-strip,
  .mapping-column-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .category-row,
  .category-add-row {
    grid-template-columns: 1fr;
  }

  .amount-comparison,
  .amount-comparison.income {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-item {
    grid-template-columns: 1fr;
  }

  .list-item-amount {
    justify-items: start;
    text-align: left;
  }

  .csv-detail-head,
  .csv-detail-totals {
    justify-content: flex-start;
  }

  .csv-detail-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .csv-detail-row span:nth-child(2),
  .csv-detail-row span:nth-child(4) {
    color: var(--muted);
    font-size: 0.78rem;
  }

  .csv-detail-row span:nth-child(3) {
    text-align: right;
  }

  .span-2 {
    grid-column: auto;
  }

  .weekday-row,
  .month-grid,
  .week-grid,
  .biweekly-grid,
  .quarterly-grid,
  .yearly-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .weekday-row {
    display: grid;
  }

  .day-cell,
  .biweekly-grid .day-cell,
  .week-grid .day-cell,
  .quarterly-grid .day-cell,
  .yearly-grid .day-cell {
    min-height: 72px;
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-rows: auto auto auto;
    gap: 10px;
    padding: 12px;
  }

  .toolbar {
    gap: 10px;
  }

  .date-controls {
    gap: 6px;
  }

  .date-controls h2 {
    font-size: 1.35rem;
  }

  .calendar-grid {
    min-height: 0;
    border-radius: 8px;
  }

  .weekday-row {
    font-size: 0.68rem;
  }

  .weekday-row div {
    padding: 0 3px 5px;
    text-align: center;
  }

  .day-cell,
  .week-grid .day-cell,
  .biweekly-grid .day-cell,
  .quarterly-grid .day-cell,
  .yearly-grid .day-cell {
    min-height: 82px;
    padding: 5px;
    gap: 4px;
  }

  .day-grid .day-cell {
    min-height: 360px;
  }

  .day-number {
    gap: 3px;
  }

  .day-select-button {
    min-width: 22px;
    height: 22px;
    padding: 0;
    font-size: 0.82rem;
    text-align: center;
  }

  .today-dot {
    width: 6px;
    height: 6px;
  }

  .cell-add-button {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    font-size: 0.86rem;
  }

  .bill-pill,
  .transaction-pill {
    border-left-width: 3px;
    padding: 4px 5px;
    gap: 1px;
  }

  .bill-pill strong,
  .transaction-pill strong,
  .transaction-pill.actual-summary .actual-title {
    font-size: 0.76rem;
  }

  .bill-pill small,
  .transaction-pill small,
  .more-count {
    font-size: 0.68rem;
    line-height: 1.15;
  }

  .month-grid .bill-pill small,
  .month-grid .transaction-pill small {
    display: none;
  }

  .month-grid .bill-pill,
  .month-grid .transaction-pill {
    min-height: 20px;
  }

  .month-grid .bill-pill:nth-of-type(n+3),
  .month-grid .transaction-pill:nth-of-type(n+3) {
    display: none;
  }

  .day-cell.is-selected {
    outline-width: 2px;
    outline-offset: -2px;
  }
}

@media (max-width: 520px) {
  .workspace,
  .sidebar {
    padding: 10px;
  }

  .day-cell,
  .week-grid .day-cell,
  .biweekly-grid .day-cell,
  .quarterly-grid .day-cell,
  .yearly-grid .day-cell {
    min-height: 58px;
    padding: 4px;
  }

  .day-select-button {
    min-width: 18px;
    height: 18px;
    font-size: 0.74rem;
  }

  .cell-add-button {
    width: 19px;
    height: 19px;
    border-radius: 6px;
    font-size: 0.78rem;
  }

  .bill-pill,
  .transaction-pill {
    padding: 3px 4px;
  }

  .bill-pill strong,
  .transaction-pill strong,
  .transaction-pill.actual-summary .actual-title {
    font-size: 0.68rem;
  }

  .more-count {
    font-size: 0.62rem;
  }
}
