@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Outfit:wght@300;400;500;600&display=swap');

:root {
  --bg: #FAF7F2;
  --bg-warm: #F0EBE3;
  --bg-dark: #2C2418;
  --fg: #2C2418;
  --fg-light: #6B5E4F;
  --fg-muted: #9C8E7D;
  --accent: #C4572A;
  --accent-light: #E8734A;
  --accent-bg: rgba(196,87,42,0.08);
  --cream: #FAF7F2;
  --border: #D9D0C4;
  --serif: 'DM Serif Display', Georgia, serif;
  --sans: 'Outfit', system-ui, sans-serif;
  --radius: 4px;
  --shadow-sm: 0 1px 3px rgba(44,36,24,0.08);
  --shadow: 0 4px 16px rgba(44,36,24,0.1);
  --transition: 0.18s ease;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── LAYOUT ── */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* ── TOPBAR ── */
.topbar {
  grid-column: 1 / -1;
  background: var(--bg-dark);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(250,247,242,0.06);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.topbar-logo {
  font-family: var(--serif);
  font-size: 1.4rem;
  color: var(--cream);
  letter-spacing: -0.01em;
  line-height: 1;
}

.topbar-tag {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-light);
  opacity: 0.8;
}

.topbar-meta {
  font-size: 0.78rem;
  color: rgba(250,247,242,0.35);
  letter-spacing: 0.04em;
}

/* ── SIDEBAR ── */
.sidebar {
  background: var(--bg-dark);
  border-right: 1px solid rgba(250,247,242,0.06);
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(250,247,242,0.25);
  padding: 0 1.25rem;
  margin-bottom: 0.4rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1.25rem;
  color: rgba(250,247,242,0.55);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 400;
  transition: color var(--transition), background var(--transition);
  border-left: 2px solid transparent;
  cursor: pointer;
}

.sidebar-link:hover {
  color: var(--cream);
  background: rgba(250,247,242,0.04);
}

.sidebar-link.active {
  color: var(--accent-light);
  border-left-color: var(--accent);
  background: rgba(196,87,42,0.08);
}

.sidebar-link .icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* ── MAIN CONTENT ── */
.main {
  background: var(--bg);
  overflow: auto;
}

.page {
  display: none;
  padding: 2rem 2.5rem;
  max-width: 1200px;
}

.page.active {
  display: block;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}

.page-title {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  color: var(--fg);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--fg-muted);
  margin-top: 0.25rem;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(196,87,42,0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--fg-light);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-warm);
  color: var(--fg);
  border-color: var(--fg-muted);
}

.btn-danger {
  background: transparent;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-sm {
  padding: 0.3rem 0.625rem;
  font-size: 0.75rem;
}

.btn-icon {
  padding: 0.3rem;
  border-radius: var(--radius);
}

/* ── TABLE ── */
.table-wrap {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--bg-warm);
}

th {
  text-align: left;
  padding: 0.625rem 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bg-warm);
  color: var(--fg);
  font-size: 0.875rem;
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(196,87,42,0.025);
}

.td-actions {
  width: 100px;
  white-space: nowrap;
}

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Outreach status */
.badge-not_contacted { background: #f1f5f9; color: #64748b; }
.badge-reached_out   { background: #fef3c7; color: #92400e; }
.badge-in_talks      { background: #dbeafe; color: #1e40af; }
.badge-committed     { background: #d1fae5; color: #065f46; }
.badge-declined      { background: #fee2e2; color: #991b1b; }

/* Contact categories */
.badge-attorney      { background: #ede9fe; color: #5b21b6; }
.badge-township      { background: #dbeafe; color: #1e40af; }
.badge-landlord      { background: #fef3c7; color: #92400e; }
.badge-investor      { background: #d1fae5; color: #065f46; }
.badge-other         { background: #f1f5f9; color: #64748b; }

/* Risk severity */
.badge-critical { background: #fee2e2; color: #991b1b; }
.badge-high     { background: #ffedd5; color: #9a3412; }
.badge-medium   { background: #fef3c7; color: #92400e; }
.badge-low      { background: #d1fae5; color: #065f46; }

/* Risk status */
.badge-open       { background: #ffe4e6; color: #881337; }
.badge-mitigated  { background: #fef3c7; color: #92400e; }
.badge-resolved   { background: #d1fae5; color: #065f46; }
.badge-accepted   { background: #f1f5f9; color: #64748b; }

/* Follow-up */
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-done     { background: #d1fae5; color: #065f46; }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44,36,24,0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

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

.modal {
  background: white;
  border-radius: 8px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  padding: 1.25rem 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--fg);
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--fg); }

.modal-body {
  padding: 1.25rem 1.5rem;
}

.modal-footer {
  padding: 0 1.5rem 1.5rem;
  display: flex;
  gap: 0.625rem;
  justify-content: flex-end;
}

/* ── FORMS ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

.form-grid .full-width {
  grid-column: 1 / -1;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--fg-light);
  text-transform: uppercase;
}

.form-input,
.form-select,
.form-textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--fg);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196,87,42,0.12);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.empty-state h3 {
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--fg-light);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--fg-muted);
  font-size: 0.875rem;
  max-width: 320px;
  margin: 0 auto 1.25rem;
}

/* ── STATS ROW ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-family: var(--serif);
  font-size: 2rem;
  color: var(--fg);
  line-height: 1;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-top: 0.25rem;
}

/* ── FILTER BAR ── */
.filter-bar {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-bar .form-input {
  max-width: 240px;
}

.filter-bar .form-select {
  width: auto;
}

/* ── NOTES CELL ── */
.notes-cell {
  color: var(--fg-muted);
  font-size: 0.82rem;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-dark);
  color: var(--cream);
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  z-index: 2000;
  transform: translateY(4px);
  opacity: 0;
  transition: all 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #991b1b;
}

/* ── CHECKBOX TOGGLE ── */
.check-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  font-size: 0.82rem;
}

.check-toggle input[type=checkbox] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .page { padding: 1.25rem; }
  .form-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}
