* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f6f8;
  color: #1b2124;
  font-size: 14px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e4e7eb;
  flex-wrap: wrap;
  gap: 8px;
}
header h1 { font-size: 16px; margin: 0; }
.user-badge { font-size: 12px; color: #6a7178; }
.role-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: #eef2f7;
  font-size: 11px;
  margin-left: 6px;
}
nav {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  background: #fff;
  border-bottom: 1px solid #e4e7eb;
}
nav button {
  border: none;
  background: transparent;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  color: #6a7178;
}
nav button.active { color: #1b6fde; border-bottom-color: #1b6fde; font-weight: 600; }
/* wide enough that the operations table (7-8 columns) has room to breathe on a
   normal desktop monitor instead of triggering .table-wrap's horizontal scroll
   just because the content area was capped narrower than the actual viewport */
main { padding: 16px; max-width: 1600px; margin: 0 auto; }
.card {
  background: #fff;
  border: 1px solid #e4e7eb;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; font-size: 11px; color: #6a7178; gap: 3px; }
input, select, button.btn {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid #d3d8dd;
  border-radius: 6px;
  background: #fff;
}
button.btn {
  cursor: pointer;
  background: #1b6fde;
  color: #fff;
  border-color: #1b6fde;
  font-weight: 500;
}
button.btn.secondary { background: #fff; color: #1b6fde; }
button.btn.danger { background: #fff; color: #d64545; border-color: #d64545; }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eef0f2; vertical-align: middle; }
th { color: #6a7178; font-weight: 600; font-size: 11px; text-transform: uppercase; white-space: nowrap; }
td:last-child .btn { padding: 4px 8px; font-size: 12px; }
@media (min-width: 641px) {
  td[data-label="Назначение"], td[data-label="Контрагент (банк)"] {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  td:last-child { white-space: nowrap; }
  /* wide operations table scrolls horizontally, but the action buttons must
     stay reachable without hunting for them at the far right edge */
  table.sticky-actions th:last-child, table.sticky-actions td:last-child {
    position: sticky;
    right: 0;
    background: #fff;
    box-shadow: -6px 0 8px -6px rgba(0,0,0,0.15);
  }
}
.amount.income { color: #1a9c4c; font-weight: 600; }
.amount.expense { color: #d64545; font-weight: 600; }
.amount.transfer { color: #6a7178; font-weight: 600; }
.chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  background: #eef2f7;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.chip.empty { color: #9aa1a8; border: 1px dashed #c7ccd1; background: transparent; }
.chip:hover { background: #dfe6ee; }
.search-box { position: relative; }
.search-results {
  position: absolute;
  top: 100%; left: 0; z-index: 10;
  background: #fff;
  border: 1px solid #d3d8dd;
  border-radius: 6px;
  min-width: 220px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.search-results div { padding: 6px 10px; cursor: pointer; font-size: 13px; }
.search-results div:hover { background: #eef2f7; }
.empty-state { color: #9aa1a8; text-align: center; padding: 30px 0; }
.section-title { font-size: 14px; font-weight: 600; margin: 0 0 10px; }
.access-row, .account-row, .category-row { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid #f0f2f4; }
.access-row .name, .account-row .label, .category-row .name { flex: 1; }
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: #1b2124; color: #fff; padding: 8px 16px; border-radius: 6px; font-size: 13px; z-index: 100;
}
.selection-summary-bar:not(:empty) {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #1b2124; color: #fff;
  padding: 10px 16px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}
.selection-summary-bar .filters { color: #fff; }
.selection-summary-bar small { color: rgba(255,255,255,0.65); }
@media (max-width: 640px) {
  main { padding: 10px; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid #e4e7eb; padding: 8px 0; }
  td { border: none; padding: 3px 0; }
  td::before { content: attr(data-label); display: block; font-size: 10px; color: #9aa1a8; text-transform: uppercase; }
}
