* { box-sizing: border-box; }

body {
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  background: #f5f6f8;
  color: #1b1f24;
}

header {
  background: #1b3a2b;
  color: #fff;
  padding: 1rem 1.5rem;
}

header h1 {
  margin: 0 0 0.75rem 0;
  font-size: 1.25rem;
}

.entity-switcher {
  margin-bottom: 0.75rem;
}

.entity-switcher label {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.entity-switcher select {
  font-weight: 600;
}

nav {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.tab-btn.active {
  background: #fff;
  color: #1b3a2b;
  font-weight: 600;
}

main {
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.tab { display: none; }
.tab.active { display: block; }

.reports-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.reports-nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 0 0 200px;
}

.report-nav-btn {
  text-align: left;
  background: #fff;
  border: 1px solid #d0d5dc;
  color: #1b3a2b;
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.report-nav-btn:hover {
  background: #eef1ee;
}

.report-nav-btn.active {
  background: #1b3a2b;
  color: #fff;
  font-weight: 600;
  border-color: #1b3a2b;
}

.reports-content {
  flex: 1;
  min-width: 0;
}

.report-view { display: none; }
.report-view.active { display: block; }

.user-block {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.user-block .toolbar {
  margin-bottom: 0.75rem;
}

.user-entity-grid {
  margin-bottom: 0;
}

.account-nickname-input {
  width: 100%;
  max-width: 200px;
}

.account-number-muted {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 0.15rem;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-hint {
  font-size: 0.85rem;
  color: #555;
  margin: -0.5rem 0 1rem 0;
}

.checks-detail-row td {
  background: #f5f6f8;
}

.checks-detail-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  columns: 2;
}

.checks-detail-list li {
  margin-bottom: 0.2rem;
  break-inside: avoid;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #eceef0;
  font-size: 0.9rem;
}

th {
  background: #eef1ee;
  font-weight: 600;
}

tr:last-child td { border-bottom: none; }

tfoot td { border-top: 2px solid #d1d5db; font-weight: 600; }

tr.row-inactive { color: #9ca3af; }
tr.row-inactive input[type="text"],
tr.row-inactive input[type="number"],
tr.row-inactive select { color: #9ca3af; }

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover { background: #e2e7e2; }

th.sortable .sort-arrow {
  display: inline-block;
  width: 1em;
  color: #6b7a6f;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: -0.5rem 0 1.5rem 0;
  font-size: 0.85rem;
}

.status-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-pending { background: #fdf1d6; color: #8a6100; }
.status-auto { background: #dbeafe; color: #1e40af; }
.status-confirmed { background: #dcfce7; color: #166534; }
.status-rejected { background: #fee2e2; color: #991b1b; }

tr.row-likely-transfer { background: #f5f3ff; }
.transfer-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #ede9fe;
  color: #5b21b6;
  margin-left: 0.4rem;
  vertical-align: middle;
}

form {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 420px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
}

input, select, button {
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #d0d5dc;
}

button {
  background: #1b3a2b;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

button:hover { opacity: 0.9; }

#add-status { font-size: 0.85rem; }

#upload-status {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0 0;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.cat-select { min-width: 180px; }

/* Payee Name / Match Text - textareas instead of single-line inputs so a
   long raw statement description wraps onto a second line instead of
   scrolling off to the right. Smaller font fits more per line too. */
#payees-table .payee-name-input,
#payees-table .payee-match-input {
  display: block;
  width: 260px;
  font-size: 0.78rem;
  line-height: 1.25;
  resize: none;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: inherit;
}

#transactions-table .vendor-input,
#needs-attention-table .vendor-input {
  display: block;
  width: 100%;
  margin-bottom: 0.3rem;
}

#transactions-table .cat-select,
#needs-attention-table .cat-select {
  display: block;
  width: 100%;
  margin-bottom: 0.3rem;
}

#transactions-table label,
#needs-attention-table label {
  font-size: 0.8rem;
  font-weight: normal;
  color: #555;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.2rem;
}

#transactions-table small,
#needs-attention-table small {
  color: #777;
}

/* ── Login screen ─────────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1b3a2b;
}

#login-screen form {
  width: 320px;
}

#login-screen h1 {
  font-size: 1.15rem;
  margin: 0 0 0.5rem 0;
  color: #1b3a2b;
}

#login-status {
  font-size: 0.85rem;
  color: #991b1b;
}

/* ── Header user info ─────────────────────────────────────────────── */
.user-info {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

header { position: relative; }

.user-info button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

/* ── Users tab ─────────────────────────────────────────────────────── */
#create-user-form fieldset {
  border: 1px solid #d0d5dc;
  border-radius: 6px;
  padding: 0.75rem;
}

#create-user-form legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: #444;
  padding: 0 0.4rem;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.4rem !important;
  font-weight: normal !important;
  margin-bottom: 0.3rem;
}

#users-table input[type="checkbox"] {
  width: auto;
  padding: 0;
}

/* ── Check image viewer ─────────────────────────────────────────────── */
.check-image-btn {
  background: none;
  border: none;
  color: #1b3a2b;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
}

.check-image-btn:hover { opacity: 0.75; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}

.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.modal-header h3 { margin: 0; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #444;
  padding: 0 0.3rem;
}

.modal-close:hover { color: #000; }

#check-image-body { text-align: center; }
#check-image-img { max-width: 100%; height: auto; border: 1px solid #d0d5dc; border-radius: 4px; }
#check-image-status { font-size: 0.9rem; color: #555; }

#create-user-status { font-size: 0.85rem; }
