/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --navy:        #1A2F5C;
  --navy-light:  #213868;
  --navy-card:   #223A6E;
  --cream:       #FAF6EE;
  --cream-dim:   #EDE8DC;
  --cream-muted: rgba(250, 246, 238, 0.62);
  --cream-faint: rgba(250, 246, 238, 0.42);
  --gold:        #C9A84C;
  --gold-hover:  #B8943A;
  --gold-muted:  rgba(201, 168, 76, 0.25);
  --gold-line:   rgba(201, 168, 76, 0.22);
  --gold-dim:    rgba(201, 168, 76, 0.12);
  --text-navy:   #1A2F5C;
  --text-cream:  #FAF6EE;
  --text-muted:  rgba(250, 246, 238, 0.6);

  --green:       #15803D;
  --green-dim:   rgba(21, 128, 61, 0.15);
  --green-border:rgba(21, 128, 61, 0.35);
  --amber:       #B45309;
  --amber-dim:   rgba(180, 83, 9, 0.15);
  --amber-border:rgba(180, 83, 9, 0.35);
  --red:         #B91C1C;
  --red-dim:     rgba(185, 28, 28, 0.12);
  --red-border:  rgba(185, 28, 28, 0.35);

  --font-serif:  'Playfair Display', Georgia, serif;
  --font-sans:   'DM Sans', system-ui, sans-serif;

  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   14px;
  --radius-xl:   999px;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.18);
  --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.12);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--navy);
  color: var(--text-cream);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

/* ── Layout shell ───────────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top nav ────────────────────────────────────────────────── */
.top-nav {
  background: var(--navy);
  border-bottom: 1px solid var(--gold-line);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-logo {
  height: 36px;
  width: auto;
}
.nav-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--cream);
  letter-spacing: 0.01em;
}
.nav-title span {
  color: var(--gold);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* User chip */
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 7px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--gold-line);
  background: rgba(201, 168, 76, 0.06);
  cursor: pointer;
  transition: background 160ms ease;
}
.user-chip:hover { background: rgba(201, 168, 76, 0.12); }
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--cream-muted);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Logout link */
.nav-logout {
  font-size: 12.5px;
  color: rgba(250, 246, 238, 0.4);
  letter-spacing: 0.01em;
  padding: 4px 0;
  transition: color 160ms ease;
  cursor: pointer;
}
.nav-logout:hover { color: var(--cream); }

/* ── Page body ──────────────────────────────────────────────── */
.page-body {
  flex: 1;
  padding: 32px 24px 64px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ── Page header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
  color: var(--cream);
  letter-spacing: -0.01em;
}
.page-subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease, transform 100ms ease, opacity 160ms ease;
  white-space: nowrap;
  border: none;
  flex-shrink: 0;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--gold);
  color: var(--navy);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--gold-hover);
  box-shadow: 0 6px 20px -6px rgba(201, 168, 76, 0.5);
}

.btn-secondary {
  background: rgba(250, 246, 238, 0.08);
  color: var(--cream);
  border: 1px solid rgba(250, 246, 238, 0.14);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(250, 246, 238, 0.13);
  border-color: rgba(250, 246, 238, 0.22);
}

.btn-ghost {
  background: transparent;
  color: var(--cream-muted);
  border: 1px solid transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(250, 246, 238, 0.07);
  color: var(--cream);
}

.btn-danger {
  background: rgba(185, 28, 28, 0.15);
  color: #F87171;
  border: 1px solid rgba(185, 28, 28, 0.3);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(185, 28, 28, 0.25);
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}
.btn-lg {
  height: 48px;
  padding: 0 24px;
  font-size: 15px;
}

/* ── Status badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-xl);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-new {
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid var(--gold-line);
}
.badge-contacted {
  background: var(--amber-dim);
  color: #FBBF24;
  border: 1px solid var(--amber-border);
}
.badge-client {
  background: var(--green-dim);
  color: #4ADE80;
  border: 1px solid var(--green-border);
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--navy-card);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ── Form controls ──────────────────────────────────────────── */
.field-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cream-faint);
  margin-bottom: 7px;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  background: rgba(250, 246, 238, 0.07);
  color: var(--cream);
  border: 1px solid rgba(250, 246, 238, 0.14);
  border-radius: var(--radius-md);
  font-size: 14.5px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-input, .field-select {
  height: 42px;
  padding: 0 13px;
}
.field-textarea {
  padding: 10px 13px;
  resize: vertical;
  min-height: 80px;
}

.field-input::placeholder,
.field-textarea::placeholder {
  color: rgba(250, 246, 238, 0.3);
}
.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.18);
}

.field-select option {
  background: var(--navy);
  color: var(--cream);
}

/* ── Search bar ─────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 380px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(250, 246, 238, 0.35);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 40px;
  padding: 0 13px 0 38px;
  background: rgba(250, 246, 238, 0.07);
  color: var(--cream);
  border: 1px solid rgba(250, 246, 238, 0.14);
  border-radius: var(--radius-md);
  font-size: 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.search-input::placeholder { color: rgba(250, 246, 238, 0.3); }
.search-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.18);
}

/* ── Data table ─────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gold-line);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead {
  background: rgba(201, 168, 76, 0.07);
  border-bottom: 1px solid var(--gold-line);
}
.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { color: var(--cream); }
.data-table th .sort-icon { margin-left: 4px; opacity: 0.5; }
.data-table th.sorted .sort-icon { opacity: 1; }

.data-table tbody tr {
  border-bottom: 1px solid rgba(201, 168, 76, 0.08);
  cursor: pointer;
  transition: background 120ms ease;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(201, 168, 76, 0.05); }

.data-table td {
  padding: 13px 16px;
  color: var(--cream-muted);
  vertical-align: middle;
}
.data-table td.td-name {
  font-weight: 500;
  color: var(--cream);
}
.data-table td.td-phone {
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.data-table td.td-muted {
  color: rgba(250, 246, 238, 0.38);
  font-size: 12.5px;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 36px;
  margin-bottom: 16px;
  opacity: 0.5;
}
.empty-state h3 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--cream-muted);
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 14px;
  max-width: 340px;
  margin: 0 auto;
}

/* ── Section label ──────────────────────────────────────────── */
.section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gold-line);
}

/* ── Modal overlay ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 180ms ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-box {
  width: 100%;
  max-width: 500px;
  background: var(--navy-card);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px -16px rgba(0,0,0,0.6);
  animation: slideUp 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--gold-line);
}
.modal-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--cream);
}
.modal-close {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: rgba(250, 246, 238, 0.07);
  color: var(--cream-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
  flex-shrink: 0;
}
.modal-close:hover {
  background: rgba(250, 246, 238, 0.13);
  color: var(--cream);
}
.modal-body {
  padding: 22px 24px;
}
.modal-footer {
  padding: 16px 24px 22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid rgba(201, 168, 76, 0.1);
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  animation: toastIn 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  max-width: 320px;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast-success { background: #15803D; color: #fff; }
.toast-error   { background: #B91C1C; color: #fff; }

/* ── Spinner ────────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(250, 246, 238, 0.2);
  border-top-color: var(--cream);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}
.spinner-gold {
  border-color: rgba(201, 168, 76, 0.25);
  border-top-color: var(--gold);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Divider ────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--gold-line);
  margin: 24px 0;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .page-body { padding: 20px 16px 48px; }
  .top-nav { padding: 0 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
