:root {
  --brand: #2E7D32;
  --brand-soft: #e8f5e9;
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --border-subtle: #e5e7eb;
  --text-main: #111827;
  --text-subtle: #6b7280;
}

body.portal-body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-main);
}

.portal-header {
  background: var(--brand);
  color: #ffffff;
  padding: 0.75rem 2rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.portal-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 100%;
  margin: 0;
}

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

.portal-nav {
  display: flex;
  gap: 0.75rem;
}

.nav-link {
  color: #e8f5e9;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
}

.nav-link-active {
  background: #ffffff;
  color: var(--brand);
  border-color: rgba(0, 0, 0, 0.05);
}

.portal-main {
  max-width: 100%;
  margin: 1.5rem auto 2rem;
  padding: 0 2rem;
}

.card {
  background: var(--card-bg);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  width: 100%;
}

.card-header {
  margin-bottom: 0.75rem;
}

.card-header h2 {
  margin: 0 0 0.25rem 0;
  font-size: 1.1rem;
}

.card-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-subtle);
}

/* Table wrapper controls scroll behavior */
.table-wrapper {
  margin-top: 0.5rem;
  width: 100%;
  position: relative;
  overflow: auto;
  max-height: calc(100vh - 320px);
}

/* Base table styles */
.table {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  white-space: nowrap;
}

.table th {
  background: #f9fafb;
  text-align: left;
}

/* Sticky header for all tables */
.table thead th {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #ffffff;
}

/* Ensure txn table header stays above everything in the wrapper */
#txnTable thead th {
  position: sticky;
  top: 0;
  z-index: 200;
  background: #ffffff;
}

/* Important: do not lock any column horizontally */
#txnTable th:nth-child(1),
#txnTable td:nth-child(1) {
  min-width: 120px;
  max-width: 120px;
  position: static;
  left: auto;
  z-index: auto;
  background: inherit;
  border-right: none;
}

/* Keep table cells from wrapping */
#txnTable th,
#txnTable td {
  white-space: nowrap;
}

/* Txn table sizing */
#txnTable {
  width: max-content;
  min-width: 2000px;
}

#txnTable select.input {
  min-width: 110px;
}

#txnTable .client-name-input {
  min-width: 140px;
}

#txnTable .client-email-input {
  min-width: 300px;
}

#txnTable .address-input {
  min-width: 320px;
}

#txnTable .contact-card-inline .input {
  min-width: 300px;
}

.table-compact th,
.table-compact td {
  white-space: nowrap;
}

.txn-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.78rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
}

/* Inputs and contact cards */
.input {
  border-radius: 0.4rem;
  border: 1px solid var(--border-subtle);
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  width: 100%;
  box-sizing: border-box;
}

.input:focus {
  outline: 2px solid rgba(46, 125, 50, 0.3);
  border-color: var(--brand);
}

.input-sm {
  font-size: 0.78rem;
  padding: 0.2rem 0.35rem;
}

.address-input {
  min-width: 260px;
  width: 100%;
}

.date-field {
  width: 110px;
}

.contact-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.contact-card-inline {
  flex-direction: row;
  align-items: center;
}

.icon-button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem 0.35rem;
}

.icon-tasks,
.icon-notes {
  font-size: 1.1rem;
}

/* Buttons */
.btn {
  border-radius: 999px;
  border: none;
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  cursor: pointer;
  background: var(--brand);
  color: #ffffff;
}

.btn:hover {
  background: #256628;
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.25rem 0.7rem;
}

.btn-outline {
  background: #ffffff;
  color: var(--brand);
  border: 1px solid var(--brand);
}

.btn-xs {
  font-size: 0.78rem;
  padding: 0.3rem 0.8rem;
  height: 34px;
}

.btn-primary {
  background: var(--brand);
  color: #ffffff;
}

.btn-primary:hover {
  background: #256628;
}

.btn-ghost {
  background: #ffffff;
  color: var(--brand);
  border: 1px solid #cfd6dd;
}

.btn-ghost:hover {
  background: var(--brand-soft);
}

a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.filters input,
.filters select,
.filters .btn {
  height: 34px;
  border-radius: 10px;
  padding: 6px 10px;
  box-sizing: border-box;
  font-size: 14px;
  line-height: 1;
}

.btn-xs {
  padding: 6px 12px;
  font-size: 14px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  width: 900px;
  max-width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.4);
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-body {
  font-size: 0.87rem;
  color: var(--text-subtle);
  margin-bottom: 0.75rem;
  overflow-y: auto;
}

.modal-footer {
  text-align: right;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
}

.hidden {
  display: none;
}


/* Row states */
.row-critical {
  background: #fff9c4;
}

.hidden-substatus {
  visibility: hidden;
}

/* inactive */
.rowactive {
  outline: 2px solid #2f7d32;
  outline-offset: -2px;
}

tr:focus-within {
  outline: 3px solid #2f7d32;
  outline-offset: -2px;
}

tr.row-active td {
  border-top: 3px solid #2f7d32;
  border-bottom: 3px solid #2f7d32;
}

tr.row-active td:first-child {
  border-left: 4px solid #2f7d32;
}

tr.row-active td:last-child {
  border-right: 3px solid #2f7d32;
}

/* Footer */
.table-footer {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-start;
}

.new-txn-row {
  background: #e8f5e9;
}

/* Notes */
.notes-timeline {
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.notes-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notes-item {
  padding: 0.35rem 0.25rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.notes-item:last-child {
  border-bottom: none;
}

.notes-item-header {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 0.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notes-item-actions {
  display: flex;
  gap: 6px;
}

.notes-item-body pre {
  margin: 0;
  font-size: 0.8rem;
  font-family: inherit;
  white-space: pre-wrap;
}

.notes-loading,
.notes-error,
.notes-empty {
  font-size: 0.8rem;
  color: #64748b;
}

.note-pinned {
  border-left: 4px solid #2e7d32;
  background: #f6fff8;
}

/* Tasks */
.tasks-groups {
  max-height: 320px;
  overflow-y: auto;
}

.tasks-groups-inner {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tasks-group-header {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.tasks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.tasks-table td {
  padding: 0.15rem 0.25rem;
}

.tasks-empty {
  font-size: 0.8rem;
  color: #94a3b8;
}

/* Reminder banner */
.banner {
  margin: 0.5rem 0 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #fff9c4;
  border: 1px solid #facc15;
}

.banner-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.banner-list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

/* Manage page layout helpers */
.toolbar-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.search-input {
  min-width: 240px;
}

.row-search-match {
  background-color: #e3f2fd;
}

.manage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.manage-header-left h2 {
  margin-bottom: 4px;
}

.manage-tabs {
  display: flex;
  gap: 8px;
}

.manage-header-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.manage-left-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.manage-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.manage-tools {
  justify-content: flex-end;
  gap: 8px;
}

.manage-search {
  display: flex;
  gap: 8px;
  align-items: center;
}

.manage-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.manage-filters-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.manage-filters-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Ongoing filters */
.row-filter-hidden {
  display: none;
}

/* Prevent whole page horizontal scroll */
html,
body {
  overflow-x: hidden;
}

/* Fix: keep Transaction ID header sticky vertically, but do not lock the column horizontally */

/* All header cells stay sticky vertically */
#txnTable thead th {
  position: sticky;
  top: 0;
  z-index: 200;
  background: #ffffff;
}

/* Specifically force the first header cell to also be sticky vertically */
#txnTable thead th:nth-child(1) {
  position: sticky;
  top: 0;
  left: auto;
  z-index: 210;
  background: #ffffff;
}

/* Do not lock the first column cells horizontally */
#txnTable tbody td:nth-child(1) {
  position: static;
  left: auto;
  z-index: auto;
  background: inherit;
}
/* Ensure popups always sit above sticky table headers */
.modal-overlay {
  z-index: 5000;
}

.modal {
  z-index: 5100;
  position: relative;
}

/* Make note timestamps bold */
.notes-item-header {
  font-weight: 600;
}

/* Remove any close delay on modals */
.modal-overlay,
.modal {
  transition: none !important;
  animation: none !important;
}

/* When hidden, instantly stop interaction and visibility */
.modal-overlay.hidden {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
