* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

header {
  background: #1a1a2e;
  color: #fff;
  padding: 1.25rem 1.5rem;
  text-align: center;
  position: relative;
}

.header-actions {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#bank-dropdown {
  position: relative;
}

#bank-dropdown-btn,
#budget-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  background: #fff;
  color: #000;
  font-weight: 600;
  cursor: pointer;
}

#budget-dropdown-btn {
  max-width: 220px;
}

#bank-dropdown-label,
#budget-dropdown-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#bank-dropdown-btn .caret,
#budget-dropdown-btn .caret {
  font-size: 0.7rem;
  color: #555;
}

#bank-menu,
#budget-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  z-index: 20;
}

#budget-menu {
  left: 0;
  min-width: 280px;
  padding: 0.35rem;
}

#bank-menu {
  right: 0;
  min-width: 320px;
  max-width: 400px;
  padding: 0 0 0.35rem;
  overflow: hidden;
}

.bank-menu-empty {
  padding: 0.75rem;
  font-size: 0.85rem;
  color: #666;
}

.bank-institution-header {
  text-align: center;
  background: #1a1a2e;
  color: #fff;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bank-institution-header:first-child {
  border-radius: 10px 10px 0 0;
}

.bank-institution-header:not(:first-child) {
  margin-top: 0.35rem;
}

.bank-account-cols {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.75rem 0.1rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
  background: transparent;
}

.bank-account-cols span:first-child {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.bank-account-cols span:last-child {
  flex: 0 0 auto;
  text-align: right;
}

.bank-account-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
  color: #1a1a2e;
  text-align: left;
}

.bank-account-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.bank-account-balance {
  flex: 0 0 auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #1a1a2e;
}

.bank-menu-item.manage,
.bank-menu-item.create-new,
.budget-menu-item.create-new {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.6rem;
  border: none;
  border-top: 1px solid #eee;
  margin-top: 0.25rem;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.bank-menu-item.manage {
  color: #1a1a2e;
  border-radius: 0;
}

.bank-menu-item.manage:hover {
  background: #f1f3f6;
}

.bank-menu-item.create-new,
.budget-menu-item.create-new {
  color: #00785a;
  border-radius: 0 0 7px 7px;
}

.bank-menu-item.create-new:hover,
.budget-menu-item.create-new:hover {
  background: #f1f3f6;
}

.bank-menu-item.create-new .plus,
.budget-menu-item.create-new .plus {
  font-size: 1.05rem;
  line-height: 1;
}

#budget-dropdown {
  position: relative;
}

/* Budget rows: a select area on the left + hover action icons on the right */
.budget-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  border-radius: 7px;
}

.budget-menu-item:hover {
  background: #f1f3f6;
}

.budget-select {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 0.55rem 0.6rem;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #1a1a2e;
  font-size: 0.9rem;
  cursor: pointer;
}

.budget-select .check {
  width: 1rem;
  flex: 0 0 auto;
  color: #2e7d32;
  font-weight: 700;
}

.budget-menu-item.selected .budget-select {
  font-weight: 700;
}

.budget-select .budget-menu-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.budget-actions {
  display: none;
  align-items: center;
  gap: 0.15rem;
  padding-right: 0.35rem;
}

.budget-menu-item:hover .budget-actions {
  display: flex;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #555;
  cursor: pointer;
}

.icon-btn:hover {
  background: #e3e7ec;
  color: #1a1a2e;
}

.icon-btn.danger:hover {
  background: #fdecea;
  color: #c62828;
}

.header-left {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#logout-btn {
  padding: 0.6rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

#logout-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

#ai-insights-btn {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  background: #fff;
  color: #000;
  font-weight: 600;
  cursor: pointer;
}

/* Login Page */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  margin-top: 12vh;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.5px;
}

.login-subtitle {
  text-align: center;
  color: #888;
  font-size: 0.9rem;
  margin: 0.35rem 0 1.5rem;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#login-form label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  margin-top: 0.6rem;
}

#login-form input {
  padding: 0.7rem 0.8rem;
  border: 1px solid #d7dbe0;
  border-radius: 8px;
  font-size: 0.95rem;
}

#login-form input:focus {
  outline: none;
  border-color: #1a1a2e;
  box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.12);
}

#login-btn {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

#login-btn:hover {
  background: #2a2a44;
}

#login-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-error {
  margin-top: 1rem;
  padding: 0.6rem 0.75rem;
  background: #fdecea;
  color: #c62828;
  border-radius: 8px;
  font-size: 0.85rem;
  text-align: center;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Dashboard toolbar */
.dash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.pay-period-label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a1a2e;
}

.dash-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.dash-btn {
  flex: 0 0 auto;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 8px;
  background: #fff;
  color: #1a1a2e;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dash-btn:hover {
  background: #f1f3f6;
}

.dash-btn-primary {
  background: #1a1a2e;
  color: #fff;
}

.dash-btn-primary:hover {
  background: #2d2d44;
}

.manual-txn-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.manual-txn-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.manual-txn-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
}

.manual-txn-field input,
.manual-txn-field select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid #d8dce3;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
}

.manual-txn-field input:focus,
.manual-txn-field select:focus {
  outline: 2px solid #1a1a2e;
  outline-offset: 1px;
}

.manual-txn-success {
  margin: 0;
  font-size: 0.85rem;
  color: #067647;
  font-weight: 600;
}

.manual-txn-error {
  margin: 0;
  font-size: 0.85rem;
  color: #b42318;
}

.manual-txn-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.txn-source-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #555;
  background: #eef0f4;
  border-radius: 4px;
  vertical-align: middle;
}

.modal-card-wide {
  max-width: min(96vw, 1164px);
  width: 100%;
  max-height: min(88vh, 820px);
}

.modal-card-wide .modal-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.txn-list-intro {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: #666;
  line-height: 1.4;
}

.txn-list-cols {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.25rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
}

.txn-list-cols .txn-col-date { flex: 0 0 3.25rem; }
.txn-list-cols .txn-col-desc { flex: 1; min-width: 0; }
.txn-list-cols .txn-col-amt { flex: 0 0 4.75rem; text-align: right; }
.txn-list-cols .txn-col-cat { flex: 0 0 11.75rem; text-align: left; }

.txn-list-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.txn-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-height: 0;
  max-height: min(68vh, 580px);
  overflow-y: auto;
}

.txn-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.25rem;
  border-bottom: 1px solid #e8eaed;
  font-size: 0.88rem;
}

.txn-row:last-child {
  border-bottom: none;
}

.txn-col-date {
  flex: 0 0 3.25rem;
  color: #666;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

.txn-col-desc {
  flex: 1;
  min-width: 0;
}

.txn-merchant {
  display: block;
  font-weight: 600;
  color: #1a1a2e;
}

.txn-sub {
  display: block;
  font-size: 0.78rem;
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.txn-col-amt {
  flex: 0 0 4.75rem;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #1a1a2e;
  font-size: 0.85rem;
}

.txn-col-amt.income {
  color: #2e7d32;
}

.txn-col-cat {
  flex: 0 0 11.75rem;
  min-width: 0;
}

.txn-col-cat-with-edit {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.txn-col-cat-with-edit .txn-category-select {
  flex: 1;
  min-width: 0;
  max-width: none;
  width: auto;
}

.txn-edit-btn {
  flex: 0 0 auto;
  padding: 0.2rem;
}

.txn-category-select {
  width: 100%;
  max-width: 10.5rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid #d0d4da;
  border-radius: 6px;
  font-size: 0.8rem;
  background: #fff;
  color: #1a1a2e;
}

.txn-category-select:disabled {
  opacity: 0.65;
  background: #f7f8fa;
}

.txn-category-label {
  font-size: 0.78rem;
  color: #888;
  font-style: italic;
}

.txn-list-empty {
  margin: 0;
  padding: 1rem 0;
  text-align: center;
  color: #666;
  font-size: 0.9rem;
}

/* Uncategorized transactions tray */
#uncategorized-tray {
  background: #1b2230;
  border: 1px solid #2a3342;
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.5rem;
  color: #e6e9ef;
}

#uncategorized-tray h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tray-count {
  background: #f0b429;
  color: #1b2230;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

.tray-hint {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  color: #9aa4b2;
}

.tray-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tray-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #141a25;
  border: 1px solid #2a3342;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  flex-wrap: wrap;
}

.tray-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tray-merchant {
  font-weight: 700;
  font-size: 0.98rem;
}

.tray-desc {
  font-size: 0.78rem;
  color: #b7c0cd;
  margin-top: 0.1rem;
}

.tray-meta {
  font-size: 0.8rem;
  color: #9aa4b2;
  margin-top: 0.1rem;
}

.tray-suggest {
  color: #6fcf97;
  margin-left: 0.4rem;
}

.tray-assign {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tray-select {
  background: #1b2230;
  color: #e6e9ef;
  border: 1px solid #2a3342;
  border-radius: 6px;
  padding: 0.45rem 0.5rem;
  max-width: 220px;
}

.tray-assign-btn {
  padding: 0.45rem 0.9rem;
  border: none;
  border-radius: 6px;
  background: #6fcf97;
  color: #10261a;
  font-weight: 700;
  cursor: pointer;
}

.tray-assign-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Summary Section */
#summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.summary-card {
  background: #fff;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.summary-card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #666;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.summary-card .value {
  font-size: 1.35rem;
  font-weight: 700;
}

.summary-card.left .value { color: #2e7d32; }
.summary-card.left.negative .value { color: #c62828; }

/* Budget Categories */
#budget-categories {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.category {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.category h2,
.category .category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.category-head-name {
  min-width: 0;
}

.category-head-pct {
  flex: 0 0 auto;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.9;
  white-space: nowrap;
}

.category table {
  width: 100%;
  border-collapse: collapse;
}

.category th {
  text-align: left;
  padding: 0.6rem 1rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #888;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #eee;
}

.category th:last-child {
  text-align: right;
}

.category td {
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid #f5f5f5;
}

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

.item-name {
  font-weight: 500;
}

.amount {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Progress Bar */
.progress-cell {
  width: 40%;
}

.progress-bar-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.progress-bar-fill.green { background: #4caf50; }
.progress-bar-fill.yellow { background: #ff9800; }
.progress-bar-fill.red { background: #f44336; }
.progress-bar-fill.over { background: #c62828; }

.progress-pct {
  font-size: 0.75rem;
  color: #666;
  min-width: 36px;
  text-align: right;
}

/* Status */
.status {
  text-align: right;
  font-weight: 600;
  font-size: 0.8rem;
}

.status.good {
  color: #2e7d32;
}

.status.zero {
  color: #b7791f;
}

.status.over {
  color: #c62828;
}

/* Total Row */
.total-row {
  background: #f8f9fa;
  font-weight: 700;
}

.total-row td {
  border-top: 2px solid #dee2e6;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

/* Loading & Error */
#loading {
  text-align: center;
  padding: 3rem;
  color: #888;
  font-size: 1rem;
}

#error {
  text-align: center;
  padding: 2rem;
  color: #c62828;
  font-size: 1rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 1rem;
  color: #aaa;
  font-size: 0.75rem;
}

/* App container */
#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
}

/* Create prompt */
.create-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 2.5rem 1.5rem;
  text-align: center;
  margin-top: 8vh;
}

.create-card h2 {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.create-card p {
  color: #777;
  margin-bottom: 1.5rem;
}

#create-budget-btn,
#save-budget-btn {
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: 8px;
  background: #1a1a2e;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

#create-budget-btn:hover,
#save-budget-btn:hover {
  background: #2a2a44;
}

#save-budget-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Builder */
.builder-head {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.builder-head h2 {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
}

.builder-field-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  margin-bottom: 0.35rem;
}

.budget-name-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #d7dbe0;
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.budget-name-input:focus {
  outline: none;
  border-color: #1a1a2e;
  box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.1);
}

.charitable-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: #333;
  cursor: pointer;
}

.charitable-toggle input {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}

#builder-sections,
#tithing-holder {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

#tithing-holder:not(:empty) {
  margin-top: 1.25rem;
}

.builder-section {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 1.25rem 1.5rem;
}

.builder-section-head h3 {
  font-size: 1.05rem;
  margin-bottom: 0.85rem;
}

.builder-rows {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.builder-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.builder-row .row-name {
  flex: 2;
}

.builder-row .row-amount {
  flex: 1;
  min-width: 0;
}

.builder-row .row-category {
  flex: 1.6;
  min-width: 0;
  padding: 0.6rem 0.7rem;
  border: 1px solid #d7dbe0;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
  color: #1a1a2e;
}

.builder-row .row-category:focus {
  outline: none;
  border-color: #1a1a2e;
  box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.1);
}

.builder-row input {
  padding: 0.6rem 0.7rem;
  border: 1px solid #d7dbe0;
  border-radius: 8px;
  font-size: 0.9rem;
}

.builder-row input:focus {
  outline: none;
  border-color: #1a1a2e;
  box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.1);
}

.remove-row-btn {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  color: #999;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.remove-row-btn:hover {
  background: #fdecea;
  color: #c62828;
  border-color: #f5c6c0;
}

.add-row-btn {
  border: 1px dashed #c4c9d0;
  border-radius: 8px;
  background: #f8f9fa;
  color: #1a1a2e;
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.add-row-btn:hover {
  background: #eef0f3;
}

.builder-footer {
  margin-top: 1.5rem;
  text-align: center;
}

.builder-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.builder-actions .secondary {
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: #1a1a2e;
  border: 1px solid #d0d4da;
}

.builder-actions .secondary:hover {
  background: #f1f3f6;
}

.builder-error {
  margin-bottom: 1rem;
  padding: 0.6rem 0.75rem;
  background: #fdecea;
  color: #c62828;
  border-radius: 8px;
  font-size: 0.85rem;
}

/* Chat (Centsei) */
.chat-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 70vh;
  max-height: 640px;
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 1.25rem;
}

.chat-title {
  font-size: 1rem;
  font-weight: 600;
}

.chat-close {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.8;
}

.chat-close:hover {
  opacity: 1;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #f7f8fa;
}

.chat-msg {
  display: flex;
}

.chat-msg.user {
  justify-content: flex-end;
}

.chat-msg .bubble {
  max-width: 80%;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.chat-msg.bot .bubble {
  background: #fff;
  color: #1a1a2e;
  border: 1px solid #ebedf0;
  border-bottom-left-radius: 4px;
}

.chat-msg.user .bubble {
  background: #1a1a2e;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bullets {
  margin: 0.5rem 0 0.1rem;
  padding-left: 1.1rem;
}

.chat-bullets li {
  margin-bottom: 0.35rem;
}

.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.1rem;
}

.chat-option {
  padding: 0.6rem 1rem;
  border: 1px solid #1a1a2e;
  border-radius: 999px;
  background: #fff;
  color: #1a1a2e;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-option:hover {
  background: #1a1a2e;
  color: #fff;
}

.chat-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.chat-select,
.chat-date {
  flex: 1 1 220px;
  min-width: 180px;
  padding: 0.55rem 0.65rem;
  border: 1px solid #c4c9d0;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #1a1a2e;
  background: #fff;
}

.chat-form-btn {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 999px;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-form-btn:hover {
  background: #2a2a44;
}

.bubble.typing {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
}

.bubble.typing .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b9bec6;
  animation: chat-blink 1.2s infinite both;
}

.bubble.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.bubble.typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* Modal overlay (bank manage, etc.) — same card feel as Centsei chat, without switching views */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.45);
}

.modal-overlay[hidden] {
  display: none;
}

body.modal-open {
  overflow: hidden;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: min(70vh, 640px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 1.25rem;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.8;
}

.modal-close:hover {
  opacity: 1;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  background: #f7f8fa;
}

.bank-manage-panel {
  padding: 0;
}

.bank-manage-intro {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #444;
}

.bank-manage-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bank-manage-empty {
  margin: 0;
  font-size: 0.9rem;
  color: #666;
}

.bank-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  background: #f7f8fa;
  border: 1px solid #e8eaed;
  border-radius: 8px;
}

.bank-manage-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.bank-manage-name {
  font-weight: 600;
  color: #1a1a2e;
}

.bank-manage-meta {
  font-size: 0.8rem;
  color: #666;
}

.bank-manage-delete {
  flex: 0 0 auto;
  padding: 0.4rem 0.75rem;
  border: 1px solid #c62828;
  border-radius: 6px;
  background: #fff;
  color: #c62828;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.bank-manage-delete:hover:not(:disabled) {
  background: #ffebee;
}

.bank-manage-delete:disabled {
  opacity: 0.6;
  cursor: default;
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid #ebedf0;
  background: #fff;
}

#chat-input {
  flex: 1;
  padding: 0.7rem 0.8rem;
  border: 1px solid #d7dbe0;
  border-radius: 8px;
  font-size: 0.92rem;
}

#chat-input:focus {
  outline: none;
  border-color: #1a1a2e;
  box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.1);
}

#chat-send {
  padding: 0.7rem 1.2rem;
  border: none;
  border-radius: 8px;
  background: #1a1a2e;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

#chat-send:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Responsive */
@media (max-width: 600px) {
  #app {
    padding: 1rem 1rem 2rem;
  }

  #summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .category th, .category td {
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
  }

  .progress-cell {
    width: 30%;
  }
}
