:root {
  --primary: #1f6f43;
  --primary-dark: #175432;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1a1d20;
  --muted: #6b7280;
  --border: #e3e7ec;
  --error: #b3261e;
  --success: #1f6f43;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.5rem;
}

.brand { font-weight: 700; font-size: 1.05rem; }
.brand span { font-weight: 400; opacity: 0.85; }

.topbar nav { display: flex; align-items: center; gap: 1rem; }
.topbar a { color: #fff; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.welcome { opacity: 0.9; font-size: 0.9rem; }

.container { max-width: 96%; margin: 2rem auto; padding: 0 1rem; flex: 1; width: 100%; box-sizing: border-box; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card.narrow { max-width: 460px; margin: 0 auto; }
.card.center { text-align: center; }

h1 { font-size: 1.5rem; margin-top: 0; }
h2 { font-size: 1.15rem; }

label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; font-size: 0.9rem; }
input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 1.25rem 0; padding: 1rem; }
legend { font-weight: 700; padding: 0 0.5rem; color: var(--primary-dark); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.req { color: var(--error); }

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.6); }
.btn-ghost:hover { background: rgba(255,255,255,0.12); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: rgba(31,111,67,0.08); }
.full { width: 100%; margin-top: 1.25rem; }
.inline { display: inline; }
.inline .btn { color: #fff; }

.flash { padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 1rem; }
.flash-error { background: #fdecea; color: var(--error); border: 1px solid #f5c6c0; }
.flash-success { background: #e7f6ec; color: var(--success); border: 1px solid #bce3c9; }

.head-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.head-row h1 { margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.mono { font-family: "SFMono-Regular", Consolas, Menlo, monospace; }

table.detail { max-width: 460px; margin: 1.25rem auto; }
table.detail th { text-align: right; width: 45%; }
table.detail td { text-align: left; }

.pill {
  display: inline-block;
  background: #fff4e5;
  color: #9a6700;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.success-badge {
  display: inline-block;
  background: #e7f6ec;
  color: var(--success);
  border: 1px solid #bce3c9;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.reference {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 1.9rem;
  letter-spacing: 0.06em;
  margin: 0.5rem 0;
  color: var(--primary-dark);
}
.actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; justify-content: center; }

.muted { color: var(--muted); font-size: 0.9rem; }
.muted a { color: var(--primary); }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 0 1.5rem;
}

.pill-pending {
  background: #fff4e5;
  color: #9a6700;
  text-decoration: none;
}
.pill-pending:hover { text-decoration: underline; }
.pill-paid {
  background: #e7f6ec;
  color: var(--success);
}

.icon-link { color: var(--primary); text-decoration: none; }
.icon-link:hover { color: var(--primary-dark); }

.ref-small { font-size: 1.2rem; margin: 0.25rem 0 1rem; }

.amount-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f0f7f2;
  border: 1px solid #cfe5d6;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
}
.amount-box strong { font-size: 1.25rem; color: var(--primary-dark); }

.pay-options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 0.5rem; }
.pay-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
}
.pay-option input { width: auto; }
.pay-option:hover { border-color: var(--primary); }

table.detail.full-width { max-width: none; }
table.detail.full-width th { width: 32%; }
.center { text-align: center; }
a.btn.center { display: block; }

.card.full-width { max-width: none; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.toolbar h2 { margin: 0; }
.search-wrap { min-width: 240px; }
.search-wrap input { width: 100%; }

th[data-sortable] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sortable]:hover { color: var(--text); }
th[data-sortable]::after { content: ' \2195'; color: #c2c8d0; }
th[data-sortable][data-dir="asc"]::after { content: ' \25B2'; color: var(--primary); }
th[data-sortable][data-dir="desc"]::after { content: ' \25BC'; color: var(--primary); }

.credentials-box {
  margin-top: 2rem;
  padding: 1rem;
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.credentials-box h3 { margin: 0 0 0.75rem; font-size: 0.9rem; color: var(--primary-dark); }
.cred-table { width: 100%; font-size: 0.8rem; border-collapse: collapse; }
.cred-table th, .cred-table td { padding: 0.35rem 0.5rem; text-align: left; border-bottom: 1px solid var(--border); }
.cred-table th { color: var(--muted); font-weight: 600; }
.cred-table tr:last-child td { border-bottom: none; }
.cred-table td:first-child { font-weight: 500; color: var(--text); }
.cred-table td:last-child { color: var(--primary-dark); font-family: monospace; font-size: 0.75rem; }

table.detail.left-align th { text-align: left; width: 35%; }
table.detail.left-align td { text-align: left; }

/* Dashboard table - reduced padding, word wrap */
#deedsTable { width: 100%; border-collapse: collapse; table-layout: fixed; }
#deedsTable th, #deedsTable td { 
  padding: 0.4rem 0.5rem; 
  white-space: normal; 
  word-wrap: break-word; 
  word-break: break-word; 
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
#deedsTable th { 
  font-size: 0.75rem; 
  text-transform: uppercase; 
  letter-spacing: 0.03em; 
  color: var(--muted); 
  font-weight: 600;
  background: #f8f9fa;
  position: sticky;
  top: 0;
}
#deedsTable td { font-size: 0.85rem; }
#deedsTable .mono { font-family: "SFMono-Regular", Consolas, Menlo, monospace; font-size: 0.75rem; }

/* Date filter form */
.date-filter { margin: 0.75rem 0 1rem; padding: 0.75rem; background: #f8f9fa; border: 1px solid var(--border); border-radius: 8px; }
.date-row { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.date-row label { font-size: 0.8rem; font-weight: 600; margin-bottom: 0.25rem; display: block; color: var(--text); }
.date-row input[type="date"] { padding: 0.4rem 0.5rem; font-size: 0.85rem; min-width: 160px; }
.date-row .btn { padding: 0.4rem 0.8rem; font-size: 0.85rem; height: fit-content; }

/* Table wrap for horizontal scroll */
.table-wrap { overflow-x: auto; max-width: 100%; }

/* Pill styles */
.pill { 
  display: inline-block; 
  padding: 0.15rem 0.5rem; 
  border-radius: 999px; 
  font-size: 0.75rem; 
  font-weight: 600; 
  white-space: nowrap;
}
.pill-pending { background: #fff4e5; color: #9a6700; text-decoration: none; }
.pill-pending:hover { text-decoration: underline; }
.pill-paid { background: #e7f6ec; color: var(--success); }

/* Icon link */
.icon-link { color: var(--primary); text-decoration: none; }
.icon-link:hover { color: var(--primary-dark); }

