/* ═══════════════════════════════════════════════════════════════════
   EWP — Engineered Wealth & Planning
   Design system for admin backend + client portal
   Matches engineeredwealth.us brand tokens.
═══════════════════════════════════════════════════════════════════ */

/* ── Brand tokens ─────────────────────────────────────────────── */
:root {
  --navy:      #0D2249;
  --navy-mid:  #163469;
  --navy-dark: #091830;
  --gold:      #C9993A;
  --gold-lt:   #E8C068;
  --gold-dk:   #b8882e;
  --light:     #F5F7FA;
  --border:    #DDE3EE;
  --text:      #1A202C;
  --muted:     #64748B;
  --white:     #ffffff;
  --radius:    8px;
  --shadow:    0 2px 12px rgba(13,34,73,.10);
  --shadow-lg: 0 4px 24px rgba(13,34,73,.14);
}

/* ── Reset (scoped to EWP pages) ──────────────────────────────── */
.ewp *, .ewp-portal * { box-sizing: border-box; }

/* ── Typography ───────────────────────────────────────────────── */
.ewp-body, .ewp-portal-body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--light);
  color: var(--text);
  line-height: 1.6;
  margin: 0;
}

/* ── EWP TOP NAV ──────────────────────────────────────────────── */
.ewp-nav {
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
  position: sticky; top: 0; z-index: 100;
}
.ewp-nav__inner {
  max-width: 1320px; margin: 0 auto;
  padding: 0 24px;
  display: flex; align-items: center; gap: 0;
  height: 60px;
}
.ewp-nav__logo {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--white);
  padding-right: 32px;
  border-right: 1px solid rgba(255,255,255,.15);
  margin-right: 20px;
  flex-shrink: 0;
}
.ewp-nav__logo img { height: 36px; }
.ewp-nav__links {
  display: flex; align-items: center;
  list-style: none; margin: 0; padding: 0;
  gap: 2px; flex: 1;
}
.ewp-nav__links a {
  display: flex; align-items: center;
  padding: 6px 14px;
  font-size: .84rem; font-weight: 500;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  border-radius: 5px;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.ewp-nav__links a:hover { background: rgba(255,255,255,.1); color: var(--white); }
.ewp-nav__links a.active {
  background: rgba(201,153,58,.18);
  color: var(--gold-lt);
}
.ewp-nav__links .nav-sep {
  width: 1px; height: 22px;
  background: rgba(255,255,255,.15);
  margin: 0 8px;
}
.ewp-nav__right {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto; padding-left: 16px;
}
.ewp-nav__right a {
  font-size: .82rem; color: rgba(255,255,255,.6);
  text-decoration: none;
  padding: 5px 10px; border-radius: 4px;
  transition: background .15s, color .15s;
}
.ewp-nav__right a:hover { background: rgba(255,255,255,.1); color: var(--white); }

/* ── FLASH MESSAGES ───────────────────────────────────────────── */
.ewp-flash { padding: 10px 24px; font-size: .9rem; }
.ewp-flash--success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.ewp-flash--error   { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }
.ewp-flash--info    { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }

/* ── MAIN CONTENT AREA ────────────────────────────────────────── */
.ewp-main { max-width: 1320px; margin: 0 auto; padding: 28px 24px 60px; }

/* ── PAGE HEADER ──────────────────────────────────────────────── */
.ewp-page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.ewp-page-header h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.75rem; font-weight: 700;
  color: var(--navy); margin: 0; line-height: 1.2;
}
.ewp-page-header .breadcrumb {
  font-size: .8rem; color: var(--muted);
  text-decoration: none; display: block; margin-bottom: 4px;
}
.ewp-page-header .breadcrumb:hover { color: var(--navy); }
.ewp-page-header__actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ── SECTION LABEL ────────────────────────────────────────────── */
.ewp-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--gold);
  margin-bottom: 6px; display: block;
}

/* ── CARDS ────────────────────────────────────────────────────── */
.ewp-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ewp-card__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}
.ewp-card__header h2, .ewp-card__header h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1rem; font-weight: 700;
  color: var(--navy); margin: 0;
}
.ewp-card__body { padding: 20px 28px; flex: 1; }
.ewp-card__footer {
  padding: 12px 20px;
  background: var(--light);
  border-top: 1px solid var(--border);
}

/* Accent left border */
.ewp-card--accent { border-left: 3px solid var(--gold); }

/* ── GRID LAYOUTS ─────────────────────────────────────────────── */
.ewp-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.ewp-grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; }
.ewp-grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 20px; }
.ewp-col-span-2 { grid-column: span 2; }
.ewp-col-span-all { grid-column: 1/-1; }

@media (max-width: 900px) {
  .ewp-grid-2, .ewp-grid-3, .ewp-grid-4 { grid-template-columns: 1fr; }
  .ewp-col-span-2, .ewp-col-span-all { grid-column: auto; }
}

/* ── STAT CARDS (dashboard) ───────────────────────────────────── */
.ewp-stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.ewp-stat__label {
  font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 8px;
}
.ewp-stat__value {
  font-size: 2rem; font-weight: 700; color: var(--navy);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.ewp-stat--gold .ewp-stat__value { color: var(--gold); }
.ewp-stat__sub { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.ewp-stat--link { display: block; text-decoration: none; transition: box-shadow .15s, transform .15s; }
.ewp-stat--link:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-2px); }

/* ── BUTTONS ──────────────────────────────────────────────────── */
.ewp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px;
  font-family: 'Inter', sans-serif;
  font-size: .875rem; font-weight: 600;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: all .15s ease; white-space: nowrap;
  line-height: 1.4;
}
.ewp-btn--primary { background: var(--gold); color: var(--white); border-color: var(--gold); }
.ewp-btn--primary:hover { background: var(--gold-dk); border-color: var(--gold-dk); color: var(--white); }
.ewp-btn--navy { background: var(--navy); color: var(--white); border-color: var(--navy); }
.ewp-btn--navy:hover { background: var(--navy-mid); border-color: var(--navy-mid); color: var(--white); }
.ewp-btn--outline { background: transparent; color: var(--navy); border-color: var(--border); }
.ewp-btn--outline:hover { border-color: var(--navy); background: var(--light); }
.ewp-btn--sm { padding: 5px 12px; font-size: .8rem; }
.ewp-btn--danger { background: #dc2626; color: var(--white); border-color: #dc2626; }
.ewp-btn--danger:hover { background: #b91c1c; border-color: #b91c1c; color: var(--white); }

/* ── BADGES (stage pills) ─────────────────────────────────────── */
.ewp-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  border-radius: 20px; white-space: nowrap;
  text-transform: capitalize;
}
/* Lead stages */
.ewp-badge--new          { background: #dbeafe; color: #1e40af; }
.ewp-badge--pre_meeting  { background: #ede9fe; color: #5b21b6; }
.ewp-badge--scope_meeting{ background: #fce7f3; color: #9d174d; }
.ewp-badge--proposal     { background: #fef3c7; color: #92400e; }
.ewp-badge--fpa          { background: #d1fae5; color: #065f46; }
.ewp-badge--onboarding   { background: #cffafe; color: #164e63; }
.ewp-badge--client       { background: #dcfce7; color: #14532d; }
.ewp-badge--closed_lost  { background: #fee2e2; color: #991b1b; }
/* Deal stages */
.ewp-badge--discovery    { background: #ede9fe; color: #4c1d95; }
.ewp-badge--active       { background: #d1fae5; color: #065f46; }
/* Client status */
.ewp-badge--active-client{ background: #d1fae5; color: #065f46; }
.ewp-badge--inactive     { background: #f1f5f9; color: #475569; }
/* Invoice status */
.ewp-badge--draft   { background: #f1f5f9; color: #475569; }
.ewp-badge--sent    { background: #fef3c7; color: #92400e; }
.ewp-badge--paid    { background: #d1fae5; color: #065f46; }
.ewp-badge--overdue { background: #fee2e2; color: #991b1b; }
.ewp-badge--warning { background: #fef3c7; color: #92400e; }

/* ── TABLES ───────────────────────────────────────────────────── */
.ewp-table-wrap { overflow-x: auto; }
.ewp-table {
  width: 100%; border-collapse: collapse;
  font-size: .875rem;
}
.ewp-table th {
  padding: 10px 14px;
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 2px solid var(--border);
  text-align: left; white-space: nowrap;
  background: var(--light);
}
.ewp-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.ewp-table tr:last-child td { border-bottom: none; }
.ewp-table tr:hover td { background: #f8f9fc; }
.ewp-table td a { color: var(--navy); font-weight: 600; text-decoration: none; }
.ewp-table td a:hover { color: var(--gold); }
.ewp-table .empty td { text-align: center; color: var(--muted); padding: 32px; }

/* ── FILTER TABS ──────────────────────────────────────────────── */
.ewp-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.ewp-tab {
  padding: 8px 16px;
  font-size: .84rem; font-weight: 500;
  color: var(--muted); text-decoration: none;
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.ewp-tab:hover { color: var(--navy); }
.ewp-tab--active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }

/* ── FORMS ────────────────────────────────────────────────────── */
.ewp-form-group { margin-bottom: 16px; }
.ewp-form-group label {
  display: block; margin-bottom: 5px;
  font-size: .82rem; font-weight: 600; color: var(--navy);
}
.ewp-form-group .hint { font-size: .75rem; color: var(--muted); margin-top: 3px; }
.ewp-input, .ewp-select, .ewp-textarea {
  width: 100%; max-width: 380px; padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: .875rem; color: var(--text);
  background: var(--white);
  transition: border-color .15s;
  line-height: 1.5;
}
.ewp-input:focus, .ewp-select:focus, .ewp-textarea:focus {
  outline: none; border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(13,34,73,.08);
}
.ewp-textarea { resize: vertical; min-height: 90px; }
.ewp-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.ewp-form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.ewp-form-group { min-width: 0; }
.ewp-form-row .ewp-input,
.ewp-form-row .ewp-select,
.ewp-form-row-3 .ewp-input,
.ewp-form-row-3 .ewp-select,
.ewp-form-row .ewp-textarea,
.ewp-form-row-3 .ewp-textarea { width: 90%; max-width: none; }
@media (max-width: 640px) {
  .ewp-form-row, .ewp-form-row-3 { grid-template-columns: 1fr; }
}
.ewp-fieldset {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 20px;
}
.ewp-fieldset legend {
  font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--gold);
  padding: 0 8px;
}
.ewp-form-actions {
  display: flex; gap: 10px; align-items: center;
  padding-top: 16px; margin-top: 4px;
  border-top: 1px solid var(--border);
}

/* ── DETAIL LIST (key-value pairs) ───────────────────────────── */
.ewp-dl {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 20px;
  font-size: .875rem;
}
.ewp-dl dt { color: var(--muted); font-weight: 500; white-space: nowrap; }
.ewp-dl dd { color: var(--text); font-weight: 400; margin: 0; }

/* ── SIMPLE LIST ──────────────────────────────────────────────── */
.ewp-list { list-style: none; margin: 0; padding: 0; }
.ewp-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  font-size: .875rem;
}
.ewp-list li:last-child { border-bottom: none; }
.ewp-list .empty { color: var(--muted); }

/* ── ACTIVITY TIMELINE ────────────────────────────────────────── */
.ewp-timeline { list-style: none; margin: 0; padding: 0; }
.ewp-timeline li {
  padding: 12px 0 12px 20px;
  border-left: 2px solid var(--border);
  margin-left: 8px;
  position: relative;
}
.ewp-timeline li::before {
  content: ''; position: absolute; left: -5px; top: 18px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--white);
}
.ewp-timeline li:last-child { border-left-color: transparent; }
.ewp-timeline .ts { font-size: .75rem; color: var(--muted); }

/* ── NOTE BLOCK ───────────────────────────────────────────────── */
.ewp-note {
  background: #fffbeb;
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 16px;
  font-size: .875rem; color: var(--text);
}

/* ── UTILITY ──────────────────────────────────────────────────── */
.ewp-muted  { color: var(--muted); }
.ewp-small  { font-size: .78rem; }
.ewp-mono   { font-family: 'Menlo','Consolas',monospace; font-size: .82rem; }
.ewp-gold   { color: var(--gold); }
.ewp-navy   { color: var(--navy); }
.ewp-fw6    { font-weight: 600; }
.ewp-ta-r                          { text-align: right; }
.ewp-ta-c                          { text-align: center; }
.ewp-table th.ewp-ta-r,
.ewp-table td.ewp-ta-r             { text-align: right; }
.ewp-table th.ewp-ta-c,
.ewp-table td.ewp-ta-c             { text-align: center; }
.ewp-mt8    { margin-top: 8px; }
.ewp-mt16   { margin-top: 16px; }
.ewp-mb0    { margin-bottom: 0; }
.ewp-text-danger { color: #dc2626; }

/* ── PORTAL-SPECIFIC ──────────────────────────────────────────── */
.ewp-portal-body { background: var(--light); }

.ewp-portal-nav {
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
}
.ewp-portal-nav__inner {
  max-width: 1080px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.ewp-portal-nav__logo img { height: 40px; }
.ewp-portal-nav__links {
  display: flex; list-style: none; margin: 0; padding: 0; gap: 4px;
}
.ewp-portal-nav__links a {
  display: block; padding: 6px 14px;
  font-size: .85rem; font-weight: 500;
  color: rgba(255,255,255,.75);
  text-decoration: none; border-radius: 5px;
  transition: background .15s, color .15s;
}
.ewp-portal-nav__links a:hover,
.ewp-portal-nav__links a.active { background: rgba(201,153,58,.2); color: var(--gold-lt); }

.ewp-portal-hero {
  background: linear-gradient(135deg, var(--navy) 0%, #1a3a6e 60%, #0a1d40 100%);
  padding: 36px 24px 28px;
  color: var(--white);
}
.ewp-portal-hero__inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: 20px;
}
.ewp-portal-hero__text {}
.ewp-portal-hero h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.6rem; font-weight: 700;
  color: var(--white); margin: 0 0 4px;
}
.ewp-portal-hero p { color: rgba(255,255,255,.7); margin: 0; font-size: .9rem; }
.ewp-portal-hero__stats {
  display: flex; gap: 24px; flex-wrap: wrap;
}
.ewp-portal-hero__stat {
  text-align: right; min-width: 100px;
}
.ewp-portal-hero__stat-label {
  font-size: .7rem; text-transform: uppercase;
  letter-spacing: .06em; color: rgba(255,255,255,.55);
  font-weight: 600;
}
.ewp-portal-hero__stat-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem; font-weight: 700;
  color: var(--gold-lt); line-height: 1.1;
}
.ewp-portal-hero__stat-sub {
  font-size: .72rem; color: rgba(255,255,255,.55);
}
.ewp-portal-login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--light); padding: 24px;
}

.ewp-portal-main {
  max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px;
}

.ewp-portal-login {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 380px; padding: 36px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.ewp-portal-login form,
.ewp-portal-login .ewp-form-group,
.ewp-portal-login .ewp-flash { width: 100%; text-align: left; }
.ewp-portal-login .ewp-input {
  padding: 7px 10px;
  font-size: .82rem;
  width: 85%;
}
.ewp-portal-login__logo {
  text-align: center; margin-bottom: 20px;
}
.ewp-portal-login__logo img { height: 56px; margin: 0 auto; }
.ewp-portal-login h1 { margin-bottom: 8px; }
.ewp-portal-login > .ewp-muted { margin-bottom: 24px; }

/* ── HAMBURGER BUTTON ─────────────────────────────────────────── */
.ewp-nav__hamburger {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  width: 36px; height: 36px;
  background: none; border: none; cursor: pointer;
  padding: 4px; margin-left: auto; flex-shrink: 0;
}
.ewp-nav__hamburger span {
  display: block; height: 2px; width: 22px;
  background: rgba(255,255,255,.8);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.ewp-nav--open .ewp-nav__hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.ewp-nav--open .ewp-nav__hamburger span:nth-child(2) { opacity: 0; }
.ewp-nav--open .ewp-nav__hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── SEARCH BAR ───────────────────────────────────────────────── */
.ewp-search {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 16px;
}
.ewp-search__input {
  flex: 1; max-width: 360px; margin-bottom: 0;
}
.ewp-btn--ghost {
  background: none; border: 1px solid transparent;
  color: var(--muted); padding: 0 12px;
}
.ewp-btn--ghost:hover { color: var(--navy); border-color: var(--border); }

/* ── PORTAL NAV — Schedule CTA (mobile-only) ──────────────────── */
.ewp-nav__schedule-cta {
  display: none;
  padding: 6px 14px;
  font-size: .8rem; font-weight: 600;
  color: var(--gold-lt); border: 1px solid var(--gold);
  border-radius: 5px; text-decoration: none;
  white-space: nowrap;
  transition: background .15s;
}
.ewp-nav__schedule-cta:hover { background: rgba(201,153,58,.15); }

/* ── NAV UNREAD BADGE ─────────────────────────────────────────── */
.ewp-nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: #27ae60; color: #fff;
  font-size: .65rem; font-weight: 700; line-height: 1;
  min-width: 16px; height: 16px; border-radius: 8px;
  padding: 0 4px; margin-left: 5px; vertical-align: middle;
}

/* ── BREADCRUMBS ──────────────────────────────────────────────── */
.ewp-breadcrumb {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: .8rem; color: var(--muted);
  margin-bottom: 20px;
}
.ewp-breadcrumb a { color: var(--muted); text-decoration: none; }
.ewp-breadcrumb a:hover { color: var(--navy); }
.ewp-breadcrumb__sep { opacity: .4; }
.ewp-breadcrumb__current { color: var(--text); font-weight: 500; }

/* ── RESPONSIVE NAV ───────────────────────────────────────────── */
.ewp-portal-nav { position: relative; }

@media (max-width: 768px) {
  .ewp-nav__hamburger { display: flex; }
  .ewp-nav__schedule-cta { display: inline-flex; align-items: center; }
  .ewp-nav__schedule-item { display: none; }
  .ewp-nav__links {
    display: none;
    position: absolute; top: 64px; left: 0; right: 0;
    background: var(--navy);
    border-top: 1px solid rgba(255,255,255,.1);
    border-bottom: 3px solid var(--gold);
    flex-direction: column; align-items: stretch;
    padding: 8px 16px 12px;
    gap: 2px; z-index: 99;
  }
  .ewp-nav--open .ewp-nav__links { display: flex; }
  .ewp-nav__links a { padding: 10px 14px; font-size: .9rem; }
  .ewp-nav__right { margin-left: 0; }
  .ewp-grid-4 { grid-template-columns: 1fr 1fr; }
  .ewp-portal-login { padding: 28px 20px; }
  .ewp-portal-login__logo img { height: 44px; }
}
