:root {
  --absa-red: #DC0032;
  --absa-red-dark: #A80026;
  --ink: #161417;
  --ink-soft: #3a3538;
  --muted: #6d676c;
  --line: #e6e1de;
  --paper: #f4f1ee;
  --surface: #fffcfa;
  --success: #0f7a45;
  --warning: #b45309;
  --info: #1d4ed8;
  --shadow: 0 4px 20px rgba(0,0,0,0.06);
  --radius: 12px;
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
}

.header {
  background: var(--surface);
  border-bottom: 3px solid var(--absa-red);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.logo-mark-img {
  width: 44px;
  height: 44px;
  display: block;
}

.logo-text { display: flex; flex-direction: column; }
.logo-text .brand {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--absa-red);
  letter-spacing: -0.5px;
  line-height: 1.1;
}
.logo-text .sub {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-badge {
  background: var(--paper);
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease;
  text-decoration: none;
}
.btn-primary { background: var(--absa-red); color: #fff; }
.btn-primary:hover { background: var(--absa-red-dark); }
.btn-secondary {
  background: var(--surface);
  color: var(--absa-red);
  border: 1.5px solid var(--absa-red);
}
.btn-secondary:hover { background: #fff5f7; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
}
.btn-outline:hover { background: var(--paper); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

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

.hero {
  background: linear-gradient(135deg, #121014 0%, #2a2428 100%);
  color: #fff;
  padding: 3.25rem 1.5rem;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.4px;
}
.hero p {
  font-size: 1.05rem;
  opacity: 0.85;
  max-width: 560px;
  margin: 0 auto;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  max-width: 420px;
  margin: -2.25rem auto 2rem;
  padding: 2rem;
  position: relative;
  z-index: 2;
}
.login-card h2 { font-size: 1.35rem; margin-bottom: 0.25rem; }
.login-card .subtitle { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.4rem; }

.form-group { margin-bottom: 1.05rem; }
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--absa-red);
  box-shadow: 0 0 0 3px rgba(220,0,50,0.12);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  border-left: 4px solid var(--absa-red);
}
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.info { border-left-color: var(--info); }
.stat-card .label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-card .value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}

.section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 1.4rem;
  margin-bottom: 1.4rem;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.section-header h3 { font-size: 1.1rem; font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--paper);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #faf9f8; }

.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-funded { background: #dbeafe; color: #1e40af; }
.badge-released { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem;
  margin: 2rem 0;
}
.feature-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.feature-card .icon-dot {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff0f3;
  color: var(--absa-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.9rem;
}
.feature-card h4 { font-size: 1rem; margin-bottom: 0.35rem; }
.feature-card p { font-size: 0.9rem; color: var(--muted); }

.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
  margin-top: 2rem;
}

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.15rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.5rem;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
}
.tab-btn.active { background: #fff0f3; color: var(--absa-red); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  padding: 1.15rem 1.4rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
}
.modal-body { padding: 1.4rem; }
.modal-footer {
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 1.4rem;
  right: 1.4rem;
  background: var(--ink);
  color: #fff;
  padding: 0.85rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 300;
  max-width: 340px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: #b91c1c; }

.amount { font-weight: 700; font-variant-numeric: tabular-nums; }

.notif-wrap { position: relative; }
.notif-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.notif-btn:hover { background: var(--paper); }
.notif-dot {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--absa-red);
  display: none;
}
.notif-dot.show { display: block; }
.notif-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(92vw, 360px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.12);
  z-index: 120;
  overflow: hidden;
}
.notif-panel.open { display: block; }
.notif-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 700;
}
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-item {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}
.notif-item:last-child { border-bottom: none; }
.notif-item .title { font-size: 0.88rem; font-weight: 700; }
.notif-item .body { font-size: 0.8rem; color: var(--ink-soft); margin-top: 0.2rem; }
.notif-item .when { font-size: 0.72rem; color: var(--muted); margin-top: 0.35rem; }

@media (max-width: 640px) {
  .header { flex-wrap: wrap; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Public activity feed — visible to buyer and seller */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.activity-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  background: #fff;
}
.activity-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-size: 0.92rem;
}
.activity-role {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
}
.activity-role.admin { background: #fff0f3; color: var(--absa-red); }
.activity-role.buyer { background: #dbeafe; color: #1e40af; }
.activity-role.seller { background: #dcfce7; color: #166534; }
.activity-body {
  margin-top: 0.35rem;
  font-size: 0.86rem;
  color: var(--ink-soft);
  line-height: 1.45;
}
.activity-meta {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--success);
}
.live-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(15,122,69,0.15);
}
.note-box {
  background: #fff8f9;
  border: 1px solid #ffe0e6;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin-bottom: 1rem;
}
