/* ─── Design Tokens ───────────────────────────────────────────────────────── */
:root {
  --color-navy:      #1a2b4a;
  --color-navy-dark: #111d33;
  --color-gold:      #c9a84c;
  --color-gold-light:#e8c96a;
  --color-bg:        #f4f5f7;
  --color-surface:   #ffffff;
  --color-border:    #dde1e9;
  --color-text:      #1a1a2e;
  --color-muted:     #6b7280;

  --color-green:     #166534;
  --color-green-bg:  #dcfce7;
  --color-amber:     #92400e;
  --color-amber-bg:  #fef3c7;
  --color-red:       #991b1b;
  --color-red-bg:    #fee2e2;
  --color-blue:      #1e40af;
  --color-blue-bg:   #dbeafe;

  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  --nav-h: 60px;
}

/* ─── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--color-navy); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ─── Navigation ──────────────────────────────────────────────────────────── */
.nav {
  background: var(--color-navy);
  height: var(--nav-h);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: .625rem;
  text-decoration: none;
}
.nav-brand-name {
  color: #fff;
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: .01em;
  white-space: nowrap;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-wrap: wrap;
}
.nav-link {
  color: rgba(255,255,255,.80);
  padding: .4rem .75rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.10); color: #fff; text-decoration: none; }
.nav-link-signout {
  color: rgba(255,255,255,.60);
  margin-left: .5rem;
  border: 1px solid rgba(255,255,255,.20);
}
.nav-link-signout:hover { background: rgba(255,255,255,.10); color: #fff; border-color: rgba(255,255,255,.40); }

/* ─── Container ───────────────────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

/* ─── Page Header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1.2;
}
.page-subtitle {
  margin-top: .375rem;
  color: var(--color-muted);
  font-size: .9rem;
}

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}
.card-placeholder {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.card-placeholder h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-navy);
}
.card-placeholder p {
  font-size: .875rem;
  color: var(--color-muted);
  flex: 1;
}
.card-icon {
  font-size: 1.5rem;
  margin-bottom: .25rem;
}

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2em .6em;
  border-radius: 9999px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-broker  { background: var(--color-navy);    color: #fff; }
.badge-agent   { background: var(--color-blue-bg); color: var(--color-blue); }
.badge-admin   { background: #f3e8ff;              color: #6b21a8; }
.badge-coming  { background: var(--color-amber-bg); color: var(--color-amber); }
.badge-active  { background: var(--color-green-bg); color: var(--color-green); }
.badge-pending { background: var(--color-amber-bg); color: var(--color-amber); }
.badge-closed  { background: #f3f4f6;              color: #374151; }
.badge-cancelled { background: var(--color-red-bg); color: var(--color-red); }

/* ─── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: .875rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}
.alert-error   { background: var(--color-red-bg);   color: var(--color-red);   border: 1px solid #fca5a5; }
.alert-success { background: var(--color-green-bg); color: var(--color-green); border: 1px solid #86efac; }
.alert-warning { background: var(--color-amber-bg); color: var(--color-amber); border: 1px solid #fcd34d; }
.alert-info    { background: var(--color-blue-bg);  color: var(--color-blue);  border: 1px solid #93c5fd; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding: .625rem 1.25rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s, opacity .15s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .92; }
.btn:active { opacity: .80; }
.btn-primary  { background: var(--color-navy); color: #fff; }
.btn-primary:hover { background: var(--color-navy-dark); }
.btn-gold     { background: var(--color-gold); color: var(--color-navy); }
.btn-gold:hover { background: var(--color-gold-light); }
.btn-outline  { background: transparent; color: var(--color-navy); border: 1.5px solid var(--color-navy); }
.btn-danger   { background: var(--color-red-bg); color: var(--color-red); border: 1px solid #fca5a5; }
.btn-sm       { padding: .375rem .875rem; font-size: .8125rem; }
.btn-full     { width: 100%; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group   { display: flex; flex-direction: column; gap: .375rem; margin-bottom: 1.125rem; }
.form-label   { font-size: .875rem; font-weight: 600; color: var(--color-text); }
.form-input,
.form-select,
.form-textarea {
  padding: .625rem .875rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .9375rem;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-navy);
  box-shadow: 0 0 0 3px rgba(26,43,74,.12);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: .8125rem; color: var(--color-muted); margin-top: .25rem; }

/* ─── Auth Layout ─────────────────────────────────────────────────────────── */
.auth-body {
  background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-navy-dark) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}
.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}
.auth-logo-initials {
  width: 60px;
  height: 60px;
  background: var(--color-navy);
  color: var(--color-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: .05em;
}
.auth-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-navy);
  text-align: center;
  margin-bottom: .25rem;
}
.auth-subtitle {
  font-size: .875rem;
  color: var(--color-muted);
  text-align: center;
  margin-bottom: 1.75rem;
}
.auth-form .btn-full { margin-top: .5rem; padding: .75rem; font-size: 1rem; }
.auth-footer {
  font-size: .8125rem;
  color: rgba(255,255,255,.45);
  text-align: center;
}

/* ─── Error Page ──────────────────────────────────────────────────────────── */
.error-page { display: flex; justify-content: center; margin-top: 4rem; }
.error-page .card { max-width: 480px; text-align: center; }
.error-title { font-size: 1.25rem; margin-bottom: 1.5rem; color: var(--color-navy); }

/* ─── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--color-border); }
th { font-weight: 600; color: var(--color-muted); font-size: .8125rem; text-transform: uppercase; letter-spacing: .04em; background: var(--color-bg); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

/* ─── Utility ─────────────────────────────────────────────────────────────── */
.text-muted   { color: var(--color-muted); }
.text-sm      { font-size: .875rem; }
.text-right   { text-align: right; }
.mt-1  { margin-top: .25rem; }
.mt-2  { margin-top: .5rem; }
.mt-4  { margin-top: 1rem; }
.mt-8  { margin-top: 2rem; }
.mb-4  { margin-bottom: 1rem; }
.flex  { display: flex; }
.gap-2 { gap: .5rem; }
.gap-4 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ─── Filter Tabs ─────────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .4rem .875rem;
  border-radius: 9999px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--color-muted);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  text-decoration: none;
  transition: all .15s;
}
.filter-tab:hover { border-color: var(--color-navy); color: var(--color-navy); text-decoration: none; }
.filter-tab.active { background: var(--color-navy); color: #fff; border-color: var(--color-navy); }
.tab-count {
  background: rgba(255,255,255,.25);
  border-radius: 9999px;
  padding: .05em .45em;
  font-size: .75rem;
  font-weight: 700;
}
.filter-tab:not(.active) .tab-count { background: var(--color-bg); color: var(--color-muted); }

/* ─── Transaction badges ──────────────────────────────────────────────────── */
.badge-type-buyer  { background: var(--color-blue-bg);  color: var(--color-blue); }
.badge-type-seller { background: #fdf4ff;               color: #7e22ce; }
.badge-type-both   { background: var(--color-amber-bg); color: var(--color-amber); }
.badge-under_contract { background: var(--color-blue-bg); color: var(--color-blue); }

/* ─── Transaction list ────────────────────────────────────────────────────── */
.tx-address { font-weight: 500; }

/* ─── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 4rem 2rem;
  background: var(--color-surface);
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
}
.empty-title { font-size: 1.125rem; font-weight: 600; color: var(--color-navy); }
.empty-body  { color: var(--color-muted); font-size: .9rem; }

/* ─── Form card / sections ────────────────────────────────────────────────── */
.form-card { display: flex; flex-direction: column; gap: 1.5rem; }
.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.form-section-title {
  font-size: .875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-muted);
  margin-bottom: 1.25rem;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.form-col-2 { grid-column: span 2; }
.form-col-1 { grid-column: span 1; }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.required { color: var(--color-red); }

/* ─── Detail page ─────────────────────────────────────────────────────────── */
.breadcrumb { font-size: .8125rem; color: var(--color-muted); margin-bottom: .375rem; }
.breadcrumb a { color: var(--color-muted); }
.breadcrumb a:hover { color: var(--color-navy); }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--color-navy); margin-bottom: 1rem; }
.detail-list { display: grid; grid-template-columns: 140px 1fr; gap: .5rem .75rem; font-size: .9rem; }
.detail-list dt { color: var(--color-muted); font-weight: 500; }
.detail-list dd { font-weight: 500; }
.notes-box {
  margin-top: 1rem;
  padding: .875rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  font-size: .875rem;
  white-space: pre-wrap;
  color: var(--color-text);
}

/* ─── Milestone timeline ──────────────────────────────────────────────────── */
.milestone-list { list-style: none; display: flex; flex-direction: column; gap: 0; }
.milestone-item {
  display: flex;
  gap: .875rem;
  align-items: flex-start;
  padding: .625rem 0;
  position: relative;
}
.milestone-item + .milestone-item::before {
  content: '';
  position: absolute;
  left: 8px;
  top: -12px;
  width: 2px;
  height: 12px;
  background: var(--color-border);
}
.milestone-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
  margin-top: .1rem;
  transition: all .15s;
}
.milestone-item.done .milestone-dot {
  background: var(--color-green);
  border-color: var(--color-green);
}
.milestone-name { font-weight: 500; font-size: .9rem; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .page-title { font-size: 1.375rem; }
  .nav-brand-name { font-size: .85rem; }
  .nav-link { padding: .35rem .5rem; font-size: .8125rem; }
  .card { padding: 1.125rem; }
  .auth-card { padding: 1.75rem 1.25rem; }
  .card-grid { grid-template-columns: 1fr; }
  .container { padding: 1.25rem 1rem; }
}
