/* =====================================================================
   DMi CRM styles. Colors live in CSS variables so the whole app can be
   rebranded to DMi's palette in one place (see :root). Desktop-first,
   but responsive enough not to break on a phone.
   ===================================================================== */
:root {
  /* ---- DMi Partners brand palette (matched to the live dmipartners.com site) ---- */
  --navy:       #1b365d;   /* primary — text, headings, chrome, key actions */
  --navy-d:     #122b4e;   /* deeper navy for gradients/hover */
  --logo-blue:  #3e6991;   /* secondary — links, subheads */
  --neon-teal:  #2cd5c4;   /* accent — active states, highlights, CTAs, positive */
  --teal-ink:   #0f8b7d;   /* darkened teal for legible text/icons on white */
  --light-blue: #b4c8da;   /* site light blue */
  --pale-blue:  #d5e1ec;
  --purple:     #9e28b5;   /* tertiary — used for AI-generated content */
  --yellow:     #ffc600;   /* tertiary — paused / caution */
  --orange:     #fe5d01;   /* tertiary — declining / danger */

  /* ---- Semantic roles mapped onto the brand ---- */
  --bg:        #f3f8fc;      /* site pale-blue background */
  --surface:   #ffffff;
  --surface-2: #f3f8fc;
  --border:    #d9e2ec;
  --text:      #1b365d;      /* navy body text */
  --text-dim:  #5f7590;      /* muted navy-gray for secondary text */
  --primary:   #1b365d;      /* navy primary buttons */
  --primary-d: #122b4e;
  --accent:    #2cd5c4;      /* neon teal */
  --link:      #3e6991;
  --ai:        #9e28b5;      /* AI-generated content accent (brand purple) */
  --ai-bg:     #f7ebfa;
  --ok:        #0f8b7d;      /* growing / positive (teal ink) */
  --warn:      #a9760a;      /* paused (readable amber derived from brand yellow) */
  --danger:    #d64500;      /* declining / destructive (brand orange, darkened) */
  --radius:    10px;
  --shadow:    0 1px 3px rgba(27,53,93,.10), 0 1px 2px rgba(27,53,93,.06);
  --font: "Aptos", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; }
.screen { min-height: 100vh; }
[hidden] { display: none !important; }

/* ---------- Buttons & controls ---------- */
.btn { font: inherit; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font-weight: 600; transition: .12s; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-danger { color: var(--danger); border-color: #f0c9c4; }
.linklike { background: none; border: none; color: var(--text-dim); cursor: pointer;
  text-decoration: underline; font: inherit; padding: 0; }
input, textarea, select { font: inherit; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; width: 100%; background: var(--surface); color: var(--text); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
textarea { resize: vertical; min-height: 72px; }
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 13px; }
.error { color: var(--danger); }
.muted { color: var(--text-dim); }

/* ---------- Login ---------- */
#loginScreen { display: grid; place-items: center;
  background: radial-gradient(1200px 700px at 50% -10%, #24406b, var(--navy) 55%, var(--navy-d)); }
.login-card { background: transparent; padding: 40px; text-align: center; max-width: 420px; }
.login-logo { width: 300px; max-width: 82%; height: auto; margin: 0 auto 18px; display: block; }
.app-tag { font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--neon-teal); font-size: 11px; }
.login-card .lead { color: var(--light-blue); margin: 14px 0 28px; line-height: 1.55; }
.fineprint { color: rgba(255,255,255,.55); font-size: 12px; margin-top: 18px; }
.fineprint b { color: rgba(255,255,255,.8); }
#loginBtn { background: var(--neon-teal); border-color: var(--neon-teal); color: var(--navy); }
#loginBtn:hover { background: #22c3b3; border-color: #22c3b3; }

/* Top-bar brand: white knockout logo + CRM tag */
.brand-home { display: inline-flex; align-items: center; gap: 9px; background: none;
  border: none; cursor: pointer; padding: 0; }
.topbar-logo { height: 22px; width: auto; display: block; }
.app-tag-sm { font-weight: 800; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--neon-teal); border: 1px solid rgba(44,213,196,.5); border-radius: 5px; padding: 1px 6px; }

/* ---------- Top bar ---------- */
#topbar { display: flex; align-items: center; gap: 20px; background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,.10); padding: 10px 20px; position: sticky; top: 0; z-index: 20; }
.topnav { display: flex; gap: 4px; }
.navlink { background: none; border: none; padding: 8px 12px; border-radius: 8px;
  font-weight: 600; color: rgba(255,255,255,.72); cursor: pointer; }
.navlink:hover { background: rgba(255,255,255,.08); color: #fff; }
.navlink.active { background: rgba(255,255,255,.08); color: #fff;
  box-shadow: inset 0 -2px 0 var(--neon-teal); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.user-chip { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.user-chip span { font-weight: 600; font-size: 13px; color: #fff; }
.user-chip .linklike { color: var(--light-blue); }
#quickAddBtn { background: var(--neon-teal); border-color: var(--neon-teal); color: var(--navy); }
#quickAddBtn:hover { background: #22c3b3; border-color: #22c3b3; }
.badge { background: var(--danger); color: #fff; border-radius: 999px; padding: 1px 7px;
  font-size: 11px; font-weight: 700; }

/* ---------- Layout ---------- */
#view { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { max-width: 180px; }
.spacer { flex: 1; }

/* ---------- Cards / table ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); }
.list { display: grid; gap: 10px; }
.acct-row { display: grid; grid-template-columns: 1.6fr 90px 1.2fr 1fr auto; gap: 12px;
  align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; box-shadow: var(--shadow); }
.acct-row:hover { border-color: var(--primary); }
.acct-name { font-weight: 700; }
.acct-sub { color: var(--text-dim); font-size: 12px; }

/* status pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 700; text-transform: capitalize; }
.pill.prospect { background: #eaf1f8; color: var(--logo-blue); }
.pill.active   { background: #e0f7f2; color: var(--ok); }
.pill.paused   { background: #fff4d6; color: var(--warn); }
.pill.former   { background: #eef2f6; color: var(--text-dim); }

/* service lines */
.svc-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; align-items: center; }
.svc-chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 4px;
  background: #eaf1f8; color: var(--logo-blue); border: 1px solid #d9e2ec; white-space: nowrap; }
.svc-chip.svc-none { background: #fff4d6; color: var(--warn); border-color: #f0d9b5; font-weight: 600; }
.svc-check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 6px 0; }
.svc-check input { width: auto; }
.filter-note { font-size: 12px; color: var(--text-dim); }
.filter-note b { color: var(--navy); }

/* sentiment scorecard */
.senti-tbl { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.senti-tbl td { padding: 4px 4px; border-bottom: 1px solid var(--border); }
.senti-tbl td.dim { color: var(--text-dim); }
.senti-tbl td.sc { text-align: right; font-weight: 700; white-space: nowrap; }
.senti-caveat { font-size: 11px; color: var(--text-dim); margin-top: 8px; font-style: italic; }
.senti-chip { font-weight: 800; }
.risk-Low { color: var(--ok); } .risk-Medium { color: var(--warn); } .risk-High { color: var(--danger); }
.pill.risk-Low { background: #e0f7f2; } .pill.risk-Medium { background: #fff4d6; } .pill.risk-High { background: #ffe3d6; }

/* health chips */
.health { font-size: 12px; font-weight: 700; display: inline-flex; gap: 5px; align-items: center; }
.health.growing   { color: var(--ok); }
.health.flat      { color: var(--text-dim); }
.health.declining { color: var(--danger); }
.health .exp { font-weight: 600; color: var(--text-dim); }

/* ---------- Account detail ---------- */
.detail-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.detail-head h1 { margin: 0; font-size: 26px; }
.detail-meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--text-dim); font-size: 13px; margin: 4px 0 20px; }
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.section { margin-bottom: 22px; }
.section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim);
  margin: 0 0 10px; }
.collapsible { cursor: pointer; user-select: none; }
.collapsible:hover { color: var(--navy); }
.chev { display: inline-block; width: 12px; color: var(--text-dim); }
.sub { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-dim); margin: 12px 0 6px; }
.panel { padding: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.chip.lead { border-color: var(--primary); color: var(--primary); }

/* notes / context stream */
.note { border-left: 3px solid var(--border); padding: 10px 14px; margin-bottom: 10px;
  background: var(--surface); border-radius: 0 8px 8px 0; }
.note.ai { border-left-color: var(--ai); background: var(--ai-bg); }
.note-meta { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.note-body { line-height: 1.5; }
.note-body.plain { white-space: pre-wrap; }
.note-title { font-weight: 700; margin-bottom: 5px; color: var(--navy); }
.note-line { margin: 2px 0; }
.note-body strong { color: var(--navy); }
.note-ul { margin: 3px 0 7px; padding-left: 18px; }
.note-ul li { margin: 1px 0; }
.ai-tag { background: var(--ai); color: #fff; border-radius: 4px; padding: 0 6px; font-size: 10px;
  font-weight: 800; letter-spacing: .3px; }
.quick-inline { display: flex; gap: 8px; margin-bottom: 16px; }
.quick-inline textarea { min-height: 44px; }

/* annotations */
.annot { border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.annot .k { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; }
.annot.proactive .k { color: var(--primary); }
.annot.retroactive .k { color: var(--warn); }

/* attention items */
.attn { border: 1px solid #f0d9b5; background: #fffaf0; border-radius: 10px; padding: 14px 16px;
  margin-bottom: 10px; }
.attn h4 { margin: 0 0 4px; }
.attn .actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Modal ---------- */
.modal-host { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16,24,40,.45); }
.modal { position: relative; background: var(--surface); border-radius: 14px; padding: 24px;
  width: min(560px, 92vw); max-height: 88vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-x { position: absolute; top: 10px; right: 14px; border: none; background: none; font-size: 26px;
  line-height: 1; cursor: pointer; color: var(--text-dim); }
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal .row { display: flex; gap: 12px; }
.modal .row > * { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1c2230; color: #fff; padding: 12px 20px; border-radius: 10px; z-index: 60;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; color: var(--text-dim); padding: 60px 20px; }
.spinner { text-align: center; padding: 60px; color: var(--text-dim); }

@media (max-width: 820px) {
  .detail-grid { grid-template-columns: 1fr; }
  .acct-row { grid-template-columns: 1fr auto; }
  .acct-row .hide-sm { display: none; }
}
