:root {
  --sidebar-w: 220px;
  --sidebar-w-collapsed: 44px;
}

/* ── Login overlay ────────────────────────────────────────────────────────── */
#login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: #1a1a2e;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: #ffffff; border-radius: 16px;
  padding: 40px 36px 36px; width: 100%; max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.login-title {
  font-size: 1.1rem; font-weight: 800; letter-spacing: 0.08em;
  text-align: center; color: #1a1a2e; line-height: 1.4; margin: 0;
}
#login-step-1, #login-step-2, #login-step-forgot, #login-step-reset {
  width: 100%; display: flex; flex-direction: column; gap: 12px;
}
#login-step-1 input, #login-step-2 input, #login-step-forgot input, #login-step-reset input {
  width: 100%; padding: 10px 14px; border: 1.5px solid #d1d5db;
  border-radius: 8px; font-size: 0.95rem; box-sizing: border-box;
  outline: none; transition: border-color 0.15s;
}
#login-step-1 input:focus, #login-step-2 input:focus, #login-step-forgot input:focus, #login-step-reset input:focus {
  border-color: #1a1a2e;
}
.login-btn {
  width: 100%; padding: 11px; background: #1a1a2e; color: #fff;
  border: none; border-radius: 8px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.login-btn:hover { background: #2d2d4e; }
.login-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.login-back-btn {
  background: none; border: none; color: #6b7280; font-size: 0.85rem;
  cursor: pointer; text-align: center; padding: 4px;
}
.login-back-btn:hover { color: #1a1a2e; }
.login-forgot-btn {
  background: none; border: none; color: #6b7280; font-size: 0.82rem;
  cursor: pointer; text-align: center; padding: 4px; margin-top: 2px;
}
.login-forgot-btn:hover { color: #1a1a2e; }
.login-error {
  color: #ef4444; font-size: 0.83rem; text-align: center; margin: 0;
  min-height: 18px;
}
.login-2fa-msg {
  font-size: 0.88rem; color: #6b7280; text-align: center; margin: 0;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.chat-cursor {
  animation: blink 0.8s step-end infinite;
  margin-left: 1px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
  padding: 90px 48px 30px 48px;
  transition: padding-left 0.25s ease;
}

body.sidebar-active {
  padding-left: calc(var(--sidebar-w) + 24px);
}

body.sidebar-collapsed {
  padding-left: calc(var(--sidebar-w-collapsed) + 24px);
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 60px;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: white;
  border-right: 1.5px solid #e5e7eb;
  z-index: 40;
  display: none;
  flex-direction: column;
  transition: width 0.25s ease;
  overflow: hidden;
}

.sidebar.visible {
  display: flex;
}

.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar-toggle-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  border-bottom: 1.5px solid #e5e7eb;
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px;
  cursor: pointer;
  font-size: 1.3rem;
  color: #aaa;
  transition: color 0.2s;
}

.sidebar.collapsed .sidebar-toggle-btn {
  justify-content: center;
}

.sidebar-toggle-btn:hover {
  color: #3b82f6;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0 20px;
  opacity: 1;
  transition: opacity 0.15s ease;
}

.sidebar.collapsed .sidebar-nav {
  opacity: 0;
  pointer-events: none;
}

.sidebar-category {
  padding: 12px 16px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #1a1a2e;
  white-space: nowrap;
}

.sidebar-account {
  display: block;
  padding: 6px 16px 6px 24px;
  font-size: 0.88rem;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  border-radius: 6px;
  margin: 0 6px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-account:hover {
  background: #f0f2f5;
  color: #1a1a2e;
}

.sidebar-account.active {
  background: #eff6ff;
  color: #3b82f6;
  font-weight: 600;
}

#screen-txhistory.active {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: #f0f2f5;
}

#screen-details.active {
  position: fixed;
  top: 60px;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: #f0f2f5;
  transition: left 0.25s ease;
}

body.sidebar-collapsed #screen-details.active {
  left: var(--sidebar-w-collapsed);
}

/* Account Setup screen — wider card to accommodate wider name field */
#screen-accounts.active {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  background: white;
  padding: 20px 28px;
  box-sizing: border-box;
}
#screen-accounts.active .net-worth-card {
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
}

/* Import screens — full viewport width */
#screen-import-transaction.active,
#screen-import-balance.active {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  background: white;
  padding: 20px 28px;
  box-sizing: border-box;
}

/* Analysis screen — full viewport height */
#screen-summary.active,
#screen-evolution.active,
#screen-custom.active {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
}

/* Analysis sub-tabs */
.analysis-tab-bar {
  display: flex;
  margin-bottom: 16px;
  background: white;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}
.analysis-tab-btn {
  flex: 1;
  padding: 11px 8px;
  border: none;
  border-right: 1.5px solid #e5e7eb;
  background: none;
  font-size: 0.88rem;
  color: #6b7280;
  cursor: pointer;
  font-weight: 500;
  text-align: center;
  transition: color 0.15s, background 0.15s;
}
.analysis-tab-btn:last-child { border-right: none; }
.analysis-tab-btn:hover { color: #1a1a2e; background: #f9fafb; }
.analysis-tab-btn.active { color: #1a1a2e; background: #f3f4f6; font-weight: 600; }

.detail-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #aaa;
  font-size: 1rem;
  pointer-events: none;
}

.row-input {
  flex: none;
  width: 100%;
  min-width: 0;
  padding: 3px 6px;
  border: 1.5px solid #3b82f6;
  border-radius: 4px;
  font-size: 0.88rem;
  background: white;
  color: #1a1a2e;
  outline: none;
  box-sizing: border-box;
}

.save-row-btn {
  color: #22c55e !important;
}

.save-row-btn:hover {
  color: #16a34a !important;
}

.detail-balance-row td {
  background: #3b82f6;
  color: white !important;
  font-weight: 700;
  padding: 12px;
}

.balance-row-action-btn {
  color: rgba(255,255,255,0.7) !important;
}

.balance-row-action-btn:hover {
  color: white !important;
  background: rgba(255,255,255,0.15);
}

.detail-balance-row .save-row-btn {
  color: rgba(255,255,255,0.7) !important;
}

.detail-balance-row .save-row-btn:hover {
  color: white !important;
}

.balance-row-input {
  background: rgba(255,255,255,0.15) !important;
  border-color: rgba(255,255,255,0.5) !important;
  color: white !important;
}

.missing-dot {
  color: #f97316;
  font-size: 0.55em;
  margin-left: 5px;
  vertical-align: middle;
}

.account-name-link {
  cursor: pointer;
}

.account-name-link:hover {
  text-decoration: underline;
}

.error-dot {
  color: #ef4444;
  font-size: 0.55em;
  margin-left: 5px;
  vertical-align: middle;
}

.incomplete-cat-dot {
  color: #eab308;
  font-size: 0.55em;
  margin-left: 5px;
  vertical-align: middle;
}

.incomplete-cat-row td {
  background: #fefce8 !important;
}

.balance-error-row td {
  background: #ef4444;
  color: white !important;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 5px 12px;
}

.detail-bottom-bar {
  display: flex;
  gap: 10px;
  padding: 12px 0 20px;
  flex-shrink: 0;
}

.detail-bottom-bar .add-account-btn {
  flex: 1;
}

.remove-rows-btn {
  color: #ef4444 !important;
  border-color: #ef4444 !important;
  margin-left: auto;
}

.remove-rows-btn:hover {
  background: #ef4444 !important;
  color: white !important;
}

.remove-rows-btn.active {
  background: #ef4444 !important;
  color: white !important;
}

.remove-sel-th {
  width: 36px;
  text-align: center !important;
}

.remove-row-checkbox {
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.detail-banner {
  padding: 24px 48px 16px;
  flex-shrink: 0;
}

.detail-actions {
  padding: 0 48px 16px;
  flex-shrink: 0;
}

.detail-table {
  width: 100%;
}

.detail-table-wrapper {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  background: white;
}

.detail-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 20px;
}

.detail-account-header {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a2e;
}

.detail-type-tag {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #3b82f6;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 20px;
  padding: 4px 12px;
  white-space: nowrap;
}

.sidebar-empty {
  padding: 16px;
  font-size: 0.85rem;
  color: #aaa;
  white-space: nowrap;
}

/* Screens */
.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* Tab Bar */
.tab-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: white;
  border-bottom: 1.5px solid #e5e7eb;
  display: flex;
  align-items: center;
  z-index: 50;
}

.action-dropdown-wrapper {
  margin-left: auto;
  display: flex;
  align-items: center;
  padding: 0 16px;
  position: relative;
}

.action-dropdown-btn {
  white-space: nowrap;
}

.action-dropdown-menu {
  display: none;
  position: absolute;
  top: 52px;
  right: 0;
  background: white;
  border: 1.5px solid #e5e7eb;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 200;
  min-width: 180px;
  flex-direction: column;
}

.action-dropdown-menu.open {
  display: flex;
}

.action-dropdown-item {
  background: none;
  border: none;
  padding: 14px 20px;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.action-dropdown-item:hover {
  background: #f0f2f5;
}

.action-dropdown-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

.action-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.action-toggle-track {
  display: inline-block;
  width: 34px;
  height: 18px;
  background: #d1d5db;
  border-radius: 9px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}

.action-toggle-track.on {
  background: #6366f1;
}

.action-toggle-track.mixed {
  background: #9ca3af;
}

.action-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.action-toggle-track.on .action-toggle-thumb {
  left: 18px;
}


.tab-bar-title {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 0.65rem;
  font-weight: 800;
  color: #1a1a2e;
  line-height: 1.4;
  letter-spacing: 0.05em;
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
  text-align: left;
}

.tab-bar-title:hover {
  color: #3b82f6;
}

.tab-bar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a1a2e;
  pointer-events: none;
}

/* Nav Drawer */
#nav-drawer {
  position: fixed;
  top: 60px;
  left: -260px;
  bottom: 0;
  width: 240px;
  background: white;
  border-right: 1.5px solid #e5e7eb;
  z-index: 80;
  display: flex;
  flex-direction: column;
  padding: 12px 0 20px;
  transition: left 0.25s ease;
  box-shadow: 2px 0 12px rgba(0,0,0,0.08);
}

#nav-drawer.open {
  left: 0;
}

#nav-overlay {
  display: none;
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.2);
  z-index: 70;
}

#nav-overlay.open {
  display: block;
}

.nav-drawer-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 12px 20px;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-radius: 6px;
  margin: 0 8px;
  width: calc(100% - 16px);
}

.nav-drawer-item:hover {
  background: #f0f2f5;
  color: #1a1a2e;
}

.nav-drawer-item.active {
  background: #eff6ff;
  color: #3b82f6;
}

.nav-drawer-divider {
  border-top: 1.5px solid #e5e7eb;
  margin: 10px 16px;
}

.nav-drawer-section {
  padding: 6px 20px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #aaa;
}

/* Categories Screen */
.categories-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

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

.categories-row-label {
  font-size: 0.95rem;
  color: #1a1a2e;
}

.categories-row .row-input {
  flex: 1;
  min-width: 0;
}

.categories-table {
  width: 100%;
}

.tabs-container {
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.tab-btn {
  flex-shrink: 0;
  white-space: nowrap;
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  font-size: 0.95rem;
  font-weight: 600;
  color: #aaa;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  padding: 0 16px;
}

.tab-btn.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
}


.analysis-dropdown-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
}

.analysis-tab-btn {
  flex: 1;
  white-space: nowrap;
  background: none;
  border: none;
  border-right: 1.5px solid #e5e7eb;
  font-size: 0.88rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  padding: 11px 8px;
  text-align: center;
}

.analysis-tab-btn:last-child { border-right: none; }

.analysis-tab-btn:hover {
  color: #1a1a2e;
  background: #f9fafb;
}

.analysis-tab-btn.active {
  color: #1a1a2e;
  background: #f3f4f6;
  font-weight: 600;
}

.analysis-dropdown-menu {
  display: none;
  position: absolute;
  top: 60px;
  left: 0;
  background: white;
  border: 1.5px solid #e5e7eb;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 200;
  min-width: 180px;
  flex-direction: column;
}

.analysis-dropdown-menu.open {
  display: flex;
}

.mobile-analysis-wrapper {
  position: relative;
}

.mobile-analysis-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  padding: 14px 20px;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: background 0.15s;
}

.mobile-analysis-btn:hover {
  background: #f0f2f5;
}

.mobile-analysis-submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  background: white;
  border: 1.5px solid #e5e7eb;
  border-radius: 0 10px 10px 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 210;
  min-width: 180px;
  flex-direction: column;
}

.mobile-analysis-submenu.open {
  display: flex;
}

.tabs-dropdown-wrapper {
  display: none;
  align-items: center;
  flex: 1;
  position: relative;
}

.tabs-dropdown-btn {
  background: none;
  border: none;
  border-bottom: 2.5px solid #3b82f6;
  height: 100%;
  padding: 0 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #3b82f6;
  cursor: pointer;
  white-space: nowrap;
}

.tabs-dropdown-menu {
  display: none;
  position: absolute;
  top: 60px;
  left: 0;
  background: white;
  border: 1.5px solid #e5e7eb;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 200;
  min-width: 180px;
  flex-direction: column;
}

.tabs-dropdown-menu.open {
  display: flex;
}

.dropdown-item {
  background: none;
  border: none;
  padding: 14px 20px;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: #f0f2f5;
}

.dropdown-item.active {
  color: #3b82f6;
}

.container {
  max-width: 700px;
  margin: 0 auto;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: #1a1a2e;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: #1a1a2e;
}

/* Summary Banner */
.summary-banner {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.summary-banner select {
  flex: none;
  min-width: 0;
  width: auto;
  padding: 6px 10px;
}

/* Net Worth Table */
.net-worth-card {
  background: white;
  border-radius: 14px;
  padding: 22px 26px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.nw-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 8px 48px;
  font-size: 1rem;
  color: #1a1a2e;
}

.nw-label {
  color: #555;
}

.nw-value {
  font-weight: 600;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.card-header-row h2 {
  margin-bottom: 0;
}

.add-account-btn {
  padding: 6px 14px;
  background: transparent;
  color: #3b82f6;
  border: 1.5px solid #3b82f6;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: 16px;
  padding: 32px;
  width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
  text-align: center;
}

.modal-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.modal-option-btn {
  padding: 12px;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 9px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a1a2e;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-option-btn:hover {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.modal-cancel-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
  padding: 0;
}

.modal-cancel-btn:hover {
  color: #ef4444;
}

.delete-modal {
  gap: 14px;
}

.delete-modal h2 {
  color: #ef4444;
}

.delete-modal-msg {
  font-size: 0.92rem;
  color: #555;
  text-align: center;
}

.delete-modal-instructions {
  font-size: 0.85rem;
  color: #888;
  text-align: center;
}

.delete-captcha-code {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: #1a1a2e;
  background: #f0f2f5;
  border-radius: 8px;
  padding: 10px 0;
  font-family: monospace;
  user-select: none;
}

.delete-confirm-btn {
  background: #ef4444;
}

.delete-confirm-btn:not(:disabled):hover {
  background: #dc2626;
}

.delete-confirm-btn:disabled {
  background: #fca5a5;
  cursor: not-allowed;
}

.modal-back-btn {
  background: none;
  border: none;
  color: #3b82f6;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-align: center;
  display: block;
  width: 100%;
}

.modal-back-btn:hover {
  text-decoration: underline;
}

.modal-save-btn {
  width: 100%;
  padding: 12px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 9px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

.modal-save-btn:hover {
  background: #2563eb;
}

#modal-step-2 {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#modal-step-2 h2 {
  margin-bottom: 0;
}

#account-name-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #f9fafb;
  color: #1a1a2e;
  outline: none;
}

#account-name-input:focus {
  border-color: #3b82f6;
  background: white;
}

/* Database Table */
.screen-fullwidth {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
}

.screen-fullwidth .db-scroll-wrapper {
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: auto;
}

.db-scroll-wrapper {
  max-height: 70vh;
  overflow-y: auto;
}

.db-table {
  width: auto;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95rem;
  table-layout: auto;
  white-space: nowrap;
}

.db-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.db-table th {
  text-align: left;
  padding: 14px 12px;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: white;
  background: #1a1a2e;
}

.db-table td {
  padding: 9px 12px;
  font-size: 0.85rem;
  border-bottom: 1px solid #f0f0f0;
  color: #1a1a2e;
}

/* Right-align amount column in detail table */
.detail-table .col-amount {
  text-align: right;
}
.detail-table .col-transaction {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sticky first 3 columns in detail table */
.detail-table th:nth-child(1),
.detail-table td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 42px;
  background: white;
}
.detail-table th:nth-child(2),
.detail-table td:nth-child(2) {
  position: sticky;
  left: 42px;
  z-index: 3;
  min-width: 110px;
  background: white;
}
.detail-table th:nth-child(3),
.detail-table td:nth-child(3) {
  position: sticky;
  left: 152px;
  z-index: 3;
  min-width: 140px;
  background: white;
}
/* Header sticky cells keep dark background */
.detail-table thead th:nth-child(1),
.detail-table thead th:nth-child(2),
.detail-table thead th:nth-child(3) {
  background: #1a1a2e;
  z-index: 4;
}
/* Balance row sticky cells keep blue background */
.detail-balance-row td:nth-child(1),
.detail-balance-row td:nth-child(2),
.detail-balance-row td:nth-child(3) {
  background: #3b82f6;
}
/* Balance error row sticky cells keep red background */
.balance-error-row td:nth-child(1),
.balance-error-row td:nth-child(2),
.balance-error-row td:nth-child(3) {
  background: #ef4444;
}
/* Incomplete category row sticky cells keep yellow background */
.incomplete-cat-row td:nth-child(1),
.incomplete-cat-row td:nth-child(2),
.incomplete-cat-row td:nth-child(3) {
  background: #fefce8;
}
/* Shadow on col 3 to show there's content behind */
.detail-table th:nth-child(3),
.detail-table td:nth-child(3) {
  box-shadow: 4px 0 6px -2px rgba(0,0,0,0.08);
}

/* Transaction History table: Date=col1, Transaction=col2 (no leading action column) */
.txhistory-table th:nth-child(1),
.txhistory-table td:nth-child(1) {
  left: 0;
  min-width: 90px;
}
.txhistory-table th:nth-child(2),
.txhistory-table td:nth-child(2) {
  left: 90px;
  min-width: 180px;
  box-shadow: 4px 0 6px -2px rgba(0,0,0,0.08);
}
.txhistory-table th:nth-child(3),
.txhistory-table td:nth-child(3) {
  position: static;
  box-shadow: none;
}
.txhistory-table thead th:nth-child(1),
.txhistory-table thead th:nth-child(2) {
  z-index: 4;
}
.txhistory-table thead th:nth-child(3) {
  z-index: 2;
}

/* Inline editable selects in transaction history rows */
.tx-inline-select {
  width: 100%;
  min-width: 80px;
  padding: 2px 4px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-size: 0.82rem;
  background: white;
  color: #1a1a2e;
  cursor: pointer;
}
.tx-inline-select:hover,
.tx-inline-select:focus {
  border-color: #3b82f6;
  outline: none;
}

/* Right-align currency columns in database table (date cols = col 3+) */
.db-table:not(.detail-table) th:nth-child(n+3),
.db-table:not(.detail-table) td:nth-child(n+3) {
  text-align: right;
}

/* Frozen columns — Account Type */
.db-table:not(.detail-table) th:nth-child(1),
.db-table:not(.detail-table) td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 2;
  background: white;
  width: 160px;
  min-width: 160px;
  max-width: 160px;
}

/* Frozen columns — Account Name */
.db-table:not(.detail-table) th:nth-child(2),
.db-table:not(.detail-table) td:nth-child(2) {
  position: sticky;
  left: 160px;
  z-index: 2;
  background: white;
  min-width: 180px;
  box-shadow: 3px 0 6px -2px rgba(0,0,0,0.12);
}

/* Header corner cells need highest z-index */
.db-table:not(.detail-table) thead th:nth-child(1),
.db-table:not(.detail-table) thead th:nth-child(2) {
  z-index: 12;
  background: #1a1a2e;
}

/* Frozen cells in type-total rows */
.db-table:not(.detail-table) .db-type-total-row td:nth-child(1),
.db-table:not(.detail-table) .db-type-total-row td:nth-child(2) {
  background: #93c5fd;
}

/* Frozen cells in net-worth row */
.db-table:not(.detail-table) .db-total-row td:nth-child(1),
.db-table:not(.detail-table) .db-total-row td:nth-child(2) {
  background: #3b82f6;
}

/* Frozen cells in inactive rows — keep white so scrolled content is covered */
.db-table:not(.detail-table) .db-row-inactive td:nth-child(1),
.db-table:not(.detail-table) .db-row-inactive td:nth-child(2) {
  background: white;
}

.tx-popup-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  table-layout: auto;
  white-space: nowrap;
}
.tx-popup-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: white;
  background: #1a1a2e;
}
.tx-popup-table td {
  text-align: left;
  padding: 8px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid #f0f0f0;
  color: #1a1a2e;
}

.context-menu {
  display: none;
  position: fixed;
  background: white;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 300;
  min-width: 150px;
  padding: 4px 0;
}

.context-menu.open {
  display: block;
}

.context-menu-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 10px 16px;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.context-menu-item:hover {
  background: #f0f2f5;
}

.context-menu-item.delete {
  color: #ef4444;
}

.db-cell-missing {
  background: #ffedd5;
}

.db-type-total-row td {
  background: #93c5fd;
  color: white;
  font-weight: 700;
  padding: 8px 12px;
}

.db-total-row td {
  background: #3b82f6;
  color: white;
  font-weight: 700;
  padding: 12px;
}

.db-empty-row td {
  color: #aaa;
  text-align: center;
  padding: 20px;
}

.db-row-inactive td {
  color: #bbb;
}

.account-inactive {
  color: #bbb !important;
}

.sidebar-category-inactive {
  color: #bbb;
  margin-top: 16px;
  border-top: 1.5px solid #e5e7eb;
  padding-top: 16px;
}

.sidebar-account-inactive {
  color: #bbb !important;
}

.sidebar-account-inactive:hover {
  color: #999 !important;
}

.account-inactive-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #bbb;
  border: 1.5px solid #ddd;
  border-radius: 20px;
  padding: 2px 8px;
}

.setup-row {
  display: flex;
  flex-direction: column;
  padding: 10px 0 30px 0;
  border-bottom: 1px solid #f0f0f0;
}

.setup-row-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 48px;
}

.setup-row-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-left: 48px;
  margin-top: 6px;
  justify-content: flex-end;
}

.setup-date-input {
  font-size: 0.78rem;
  padding: 4px 6px;
  border: 1.5px solid #e5e7eb;
  border-radius: 6px;
  background: #f9fafb;
  color: #1a1a2e;
  cursor: pointer;
  width: 130px;
  min-width: 0;
  flex: none;
}

.setup-col-label {
  font-size: 0.7rem;
  color: #9ca3af;
  text-align: center;
  width: 130px;
  flex: none;
}

.setup-date-input:focus {
  border-color: #3b82f6;
  background: white;
  outline: none;
}

.setup-date-input--error {
  border-color: #ef4444 !important;
  background: #fff5f5;
}

.setup-date-input:disabled {
  color: #ccc;
  border-color: #f0f0f0;
  background: #fafafa;
  cursor: default;
}

.db-actions {
  text-align: right;
  white-space: nowrap;
}

.setup-category-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 18px;
  cursor: default;
}


.setup-row.dragging {
  opacity: 0.4;
}

.setup-row.drag-over-top {
  border-top: 2px solid #3b82f6;
}

.setup-row.drag-over-bottom {
  border-bottom: 2px solid #3b82f6;
}


.setup-empty {
  color: #aaa;
  font-size: 0.9rem;
  padding: 16px 0;
}

.row-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #ccc;
  padding: 2px 5px;
  border-radius: 5px;
  transition: color 0.2s;
  line-height: 1;
}

.row-action-btn:hover {
  color: #3b82f6;
}

.row-action-btn.delete:hover {
  color: #ef4444;
}

.add-account-btn:hover {
  background: #3b82f6;
  color: white;
}

.section-subheader {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #1a1a2e;
  margin: 18px 0 18px;
}

.nw-divider {
  border-top: 1.5px solid #1a1a2e;
  margin: 6px 0 6px 48px;
}

.nw-total .nw-label {
  font-weight: 700;
  color: #1a1a2e;
}

.nw-total .nw-value {
  font-weight: 700;
  font-size: 1.1rem;
}

/* Form Card */
.form-card {
  background: white;
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.form-row:last-child {
  margin-bottom: 0;
}

input[type="text"],
input[type="number"],
select {
  flex: 1;
  min-width: 120px;
  padding: 10px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #f9fafb;
  color: #1a1a2e;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus {
  border-color: #3b82f6;
  background: white;
}

.type-toggle {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.9rem;
}

.type-toggle label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

button#add-btn {
  padding: 10px 24px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

button#add-btn:hover {
  background: #2563eb;
}

/* Transactions Card */
.transactions-card {
  background: white;
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.transactions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

button#clear-btn {
  padding: 6px 14px;
  background: transparent;
  color: #ef4444;
  border: 1.5px solid #ef4444;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

button#clear-btn:hover {
  background: #ef4444;
  color: white;
}

#transaction-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-message {
  color: #aaa;
  font-size: 0.9rem;
  text-align: center;
  padding: 20px 0;
}

.transaction-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 48px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1.5px solid #f0f0f0;
}

.transaction-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.transaction-desc {
  font-weight: 600;
  font-size: 0.95rem;
}

.transaction-meta {
  font-size: 0.78rem;
  color: #888;
}

.transaction-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.transaction-amount {
  font-weight: 700;
  font-size: 1rem;
}

.transaction-amount.income { color: #22c55e; }
.transaction-amount.expense { color: #ef4444; }

.delete-btn {
  background: none;
  border: none;
  color: #ccc;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 5px;
  transition: color 0.2s;
  line-height: 1;
}

.delete-btn:hover {
  color: #ef4444;
}

/* Import Transaction — Step 3 review table */
#screen-import-transaction .db-scroll-wrapper {
  max-height: calc(100vh - 220px);
}

#screen-import-transaction input[type="date"],
#screen-import-transaction input[type="text"],
#screen-import-transaction input[type="number"],
#screen-import-transaction select {
  font-family: inherit;
  font-size: 0.8rem;
}

#screen-import-transaction input[type="date"]:focus,
#screen-import-transaction input[type="text"]:focus,
#screen-import-transaction input[type="number"]:focus,
#screen-import-transaction select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
