/* ===========================================================================
   TFC CRM — The Franchise Consultant
   Brand tokens live here. Swap these three to re-skin the whole app.
   =========================================================================== */
:root {
  /* TFC brand palette (from Brand Stylesheet - Digital/RGB) */
  --tfc-navy: #101727;      /* primary brand dark */
  --tfc-navy-700: #171f32;  /* secondary dark */
  --tfc-navy-600: #222c45;  /* lighter panel/active */
  --tfc-orange: #ff611d;    /* primary accent */
  --tfc-amber: #ffa80a;     /* secondary accent */
  --tfc-gold: #ffa80a;      /* alias kept for existing rules */
  --tfc-grey: #cccfd3;

  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e4e8ee;
  --text: #1c2430;
  --muted: #697588;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: 'Roboto', system-ui, -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; }

.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }

/* ---- Sidebar ------------------------------------------------------------ */
.sidebar {
  background: var(--tfc-navy);
  color: #cdd8e6;
  display: flex; flex-direction: column;
  padding: 18px 14px;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 6px 18px; }
.brand-logo { width: 150px; max-width: 100%; height: auto; display: block; }
.brand-sub { color: var(--tfc-amber); font-size: 11px; letter-spacing: 4px; text-transform: uppercase; font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 8px;
  color: #b7c4d6; text-decoration: none; font-weight: 500; font-size: 13.5px;
}
.nav-item .nav-ico {
  width: 22px; height: 22px; border-radius: 6px;
  background: rgba(255,255,255,.08); color: #e7eef7;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.nav-item:hover { background: var(--tfc-navy-700); color: #fff; }
.nav-item.active { background: var(--tfc-navy-600); color: #fff; }
.nav-item.active .nav-ico { background: var(--tfc-orange); color: #fff; }
.nav-item.disabled { color: #6a7d95; opacity: .65; cursor: default; }
.nav-item .soon {
  margin-left: auto; font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .5px; background: rgba(255,255,255,.07);
  padding: 2px 6px; border-radius: 20px;
}
.sidebar-foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.08); }
.loc { font-size: 12px; color: #8ea0b7; }
.whoami { margin-bottom: 10px; }
.whoami-name { font-size: 13px; color: #dde6f2; font-weight: 600; word-break: break-word; }
.whoami-admin { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: #0b2a4a; background: var(--tfc-gold); border-radius: 4px; padding: 1px 5px; margin-left: 4px; vertical-align: middle; }
.whoami-warn { font-size: 11px; color: #f1b86b; margin-top: 3px; line-height: 1.4; }
.whoami-warn a { color: #f1b86b; text-decoration: underline; }
.whoami-logout { display: inline-block; margin-top: 6px; font-size: 12px; color: #8ea0b7; text-decoration: none; }
.whoami-logout:hover { color: #dde6f2; }

/* ---- Main / topbar ------------------------------------------------------ */
.main { overflow: hidden; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; }
.pipeline-select select {
  appearance: none; border: 1px solid var(--line); background: #fbfcfe;
  padding: 8px 32px 8px 12px; border-radius: 8px; font-weight: 600; color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23697588' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; cursor: pointer;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.view-toggle { display: inline-flex; background: #eef1f6; border-radius: 8px; padding: 3px; }
.view-toggle a {
  padding: 6px 14px; border-radius: 6px; text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: 13px;
}
.view-toggle a.on { background: #fff; color: var(--tfc-navy); box-shadow: var(--shadow); }
.btn-primary {
  background: var(--tfc-navy); color: #fff; border: 0; padding: 9px 15px;
  border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 13.5px;
}
.btn-primary:hover { background: var(--tfc-navy-600); }
.btn-ghost { background: #eef1f6; color: var(--text); border: 0; padding: 9px 15px; border-radius: 8px; font-weight: 600; cursor: pointer; }

/* ---- KPIs --------------------------------------------------------------- */
.kpis { display: flex; gap: 14px; padding: 16px 24px 4px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; min-width: 190px; box-shadow: var(--shadow);
}
.kpi.accent { border-color: var(--tfc-gold); background: linear-gradient(180deg,#fffdf7,#fff); }
.kpi-label { display: block; color: var(--muted); font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--tfc-navy); }
.hint { display:inline-grid; place-items:center; width:15px; height:15px; border-radius:50%;
  background:#eef1f6; color:var(--muted); font-size:10px; cursor:help; }

/* ---- Board -------------------------------------------------------------- */
.board {
  display: flex; gap: 14px; padding: 16px 24px 24px; overflow-x: auto; flex: 1;
  align-items: flex-start;
}
.col {
  background: #eef1f5; border-radius: 12px; width: 280px; flex: 0 0 280px;
  display: flex; flex-direction: column; max-height: 100%;
}
.col-head { padding: 12px 14px 10px; border-bottom: 1px solid #e1e6ee; }
.col-title { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.col-title .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: color-mix(in srgb, var(--tfc-gold) calc(var(--p) * 1%), var(--tfc-navy));
}
.col-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.col-meta .count {
  background: var(--tfc-navy); color: #fff; font-size: 11px; font-weight: 700;
  padding: 1px 8px; border-radius: 20px;
}
.col-value { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.prob { color: #9aa6b6; font-size: 11px; margin-top: 4px; }

.col-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; min-height: 40px; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px;
  box-shadow: var(--shadow); cursor: grab;
}
.card:active { cursor: grabbing; }
.card-name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.card-franchise { color: var(--muted); font-size: 11.5px; margin-top: 5px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--tfc-navy-600);
  color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 700;
}
.card-value { font-weight: 700; color: var(--tfc-navy); font-size: 13px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tag {
  background: var(--tfc-gold-600, #faf1dc); color: #8a6a12; font-size: 10.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px; background: #faf1dc;
}

/* drag states */
.sortable-ghost { opacity: .4; }
.sortable-drag { box-shadow: 0 8px 24px rgba(11,42,74,.25); }
.col-body.drop-hot { background: #e5ecf5; border-radius: 8px; outline: 2px dashed var(--tfc-navy-600); outline-offset: -4px; }

/* ---- List view ---------------------------------------------------------- */
.list-wrap { padding: 16px 24px; overflow: auto; flex: 1; }
.opp-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.opp-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #f8fafc; padding: 11px 14px; }
.opp-table td { padding: 11px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.opp-table td.num, .opp-table th.num { text-align: right; }
.opp-table .strong { font-weight: 600; }
.opp-table .muted { color: var(--muted); }
.stage-chip { background: #eef1f6; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; color: var(--tfc-navy); }

/* ---- Placeholder / modal ------------------------------------------------ */
.placeholder { padding: 48px 24px; max-width: 620px; }
.placeholder h2 { color: var(--tfc-navy); }
.placeholder p { color: var(--muted); line-height: 1.6; }

.modal-overlay { position: fixed; inset: 0; background: rgba(11,42,74,.4); display: grid; place-items: center; z-index: 50; }
.modal-overlay[hidden] { display: none; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: 420px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 14px; color: var(--tfc-navy); }
.modal label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 11px; }
.modal input, .modal select { width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; font-family: inherit; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---- Type-ahead + modal extras ----------------------------------------- */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-hint { color: var(--muted); font-size: 11.5px; margin: -4px 0 12px; }
.lookup-tag { font-size: 9.5px; text-transform: uppercase; letter-spacing: .4px;
  background: #faf1dc; color: #8a6a12; padding: 1px 6px; border-radius: 20px; font-weight: 700; }
.typeahead { position: relative; }
.typeahead-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16,24,40,.12); max-height: 220px; overflow-y: auto;
}
.ta-item { display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; cursor: pointer; font-size: 13px; }
.ta-item:hover { background: #f1f5fb; }
.ta-sector { color: var(--muted); font-size: 11px; }

/* ---- Contacts ----------------------------------------------------------- */
.page { padding: 18px 24px; overflow: auto; flex: 1; }
.page h1 { margin: 0 0 4px; }
.search-row { margin: 14px 0; }
.search-row input { width: 320px; max-width: 60vw; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 13.5px; font-family: inherit; }
.contact-table { width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.contact-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); background: #f8fafc; padding: 11px 14px; }
.contact-table td { padding: 11px 14px; border-top: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
.contact-table tr:hover td { background: #fafbfd; }
.c-name { display: flex; align-items: center; gap: 10px; }
.c-name a { color: var(--tfc-navy); font-weight: 600; text-decoration: none; }
.c-name a:hover { text-decoration: underline; }
.id-list { display: flex; flex-direction: column; gap: 2px; }
.id-list small { color: var(--muted); }
.pill { background: #eef1f6; color: var(--tfc-navy); font-size: 11px; font-weight: 700;
  padding: 1px 8px; border-radius: 20px; }

.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.detail-head .avatar { width: 46px; height: 46px; font-size: 16px; }
.detail-grid { display: grid; grid-template-columns: 320px 1fr; gap: 20px; margin-top: 16px; align-items: start; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.kv { margin-bottom: 11px; }
.kv .k { font-size: 11px; color: var(--muted); display: block; }
.kv .v { font-size: 13.5px; }
.opp-block { border: 1px solid var(--line); border-radius: 10px; padding: 13px 15px; margin-bottom: 14px; }
.opp-block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.opp-block-head .t { font-weight: 600; }
.opp-block-head .meta { color: var(--muted); font-size: 12px; }
.note { background: #f8fafc; border-left: 3px solid var(--tfc-gold); border-radius: 6px;
  padding: 8px 11px; margin-top: 9px; font-size: 13px; }
.note .note-meta { color: var(--muted); font-size: 11px; margin-top: 4px; }
.back-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.back-link:hover { color: var(--tfc-navy); }
.merge-flag { background: #fff6e6; border: 1px solid var(--tfc-gold); color: #8a6a12;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }

.chip-wrap { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { background: #f1f5fb; border: 1px solid var(--line); color: var(--text);
  font-size: 12px; padding: 4px 10px; border-radius: 20px; }

/* ---- Cleanup tool ------------------------------------------------------- */
.btn-primary.sm, .btn-ghost.sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.act-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.typeahead.sm input { padding: 6px 9px; font-size: 12px; border: 1px solid var(--line);
  border-radius: 7px; width: 150px; font-family: inherit; }
.sug { font-weight: 600; }
.score { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; margin-left: 6px; }
.score.hi { background: #e5f6ec; color: #1a7f44; }
.score.lo { background: #fdeede; color: #b4600f; }
.done-pill { background: #e5f6ec; color: #1a7f44; font-weight: 600; font-size: 12.5px;
  padding: 5px 11px; border-radius: 20px; }
.muted { color: var(--muted); }
#cleanupTable td { vertical-align: middle; }
.more-note { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--muted);
  padding: 6px; border-top: 1px dashed var(--line); margin-top: 2px; }
.pager { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.pager-info { font-size: 12.5px; color: var(--muted); }

/* ---- Franchisees -------------------------------------------------------- */
.status-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px;
  text-transform: capitalize; }
.status-badge.active { background: #e5f6ec; color: #1a7f44; }
.status-badge.onboarding { background: #fff4d9; color: #9a6b00; }
.status-badge.resigned { background: #f1f1f4; color: #6a6f7a; }
.status-select { font-family: inherit; font-size: 12px; font-weight: 600; padding: 4px 8px;
  border-radius: 7px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.status-select.active { color: #1a7f44; }
.status-select.onboarding { color: #9a6b00; }
.status-select.resigned { color: #6a6f7a; }
.assign-fr .typeahead-list, .typeahead .typeahead-list { position: absolute; z-index: 30; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-item { padding: 7px 13px; font-size: 12.5px; font-weight: 600; color: var(--muted);
  text-decoration: none; border-left: 1px solid var(--line); }
.seg-item:first-child { border-left: 0; }
.seg-item.on { background: var(--tfc-navy); color: #fff; }

/* ---- Dashboard ---------------------------------------------------------- */
.dash-kpis { flex-wrap: wrap; padding: 4px 0 0; }
.dash-kpis .kpi { flex: 1 1 150px; min-width: 150px; }
.kpi-sub { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; align-items: start; }
.dash-grid .panel.span2 { grid-column: 1 / -1; }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; border-radius: 50%; position: relative; flex: 0 0 auto; }
.donut-hole { position: absolute; inset: 26px; background: #fff; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-big { font-size: 24px; font-weight: 800; color: var(--tfc-navy); line-height: 1; }
.donut-small { font-size: 11px; color: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; flex: 1 1 160px; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.legend .dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.legend-label { font-weight: 600; color: var(--tfc-navy); }
.legend-val { margin-left: auto; color: var(--muted); font-size: 12px; }
.barset { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 10px; }
.bar-label { font-size: 12.5px; font-weight: 600; color: var(--tfc-navy); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.bar-label a { color: var(--tfc-navy); text-decoration: none; }
.bar-label a:hover { text-decoration: underline; }
.bar-track { background: #eef1f6; border-radius: 20px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; min-width: 2px;
  background: linear-gradient(90deg, var(--tfc-orange), var(--tfc-amber)); }
.bar-fill.alt { background: linear-gradient(90deg, var(--tfc-navy), #46506e); }
.bar-fill.green { background: linear-gradient(90deg, #1a7f44, #39b26a); }
.bar-val { font-size: 12.5px; font-weight: 700; color: var(--tfc-navy); min-width: 52px; text-align: right; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* ---- Conversations inbox ------------------------------------------------- */
.sim-banner { margin: 0 24px 0; padding: 10px 14px; background: #fff4d9; color: #7a5600;
  border: 1px solid #ffe3a3; border-radius: 10px; font-size: 12.5px; }
.sim-banner code { background: #fff; padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 0; margin: 16px 24px 24px;
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff;
  height: calc(100vh - 150px); box-shadow: var(--shadow); }
.inbox-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.inbox-tools { padding: 12px; border-bottom: 1px solid var(--line); }
.inbox-search { width: 100%; padding: 8px 11px; border: 1px solid var(--line);
  border-radius: 8px; font-family: inherit; font-size: 13px; }
.conv-items { overflow-y: auto; flex: 1; min-height: 0; }
.conv-item { display: flex; align-items: center; gap: 11px; padding: 11px 13px;
  border-bottom: 1px solid var(--line); text-decoration: none; position: relative; }
.conv-item:hover { background: #fafbfd; }
.conv-item.on { background: #eef2f9; }
.conv-meta { min-width: 0; flex: 1; }
.conv-top { display: flex; align-items: center; gap: 7px; }
.conv-name { font-weight: 600; color: var(--tfc-navy); font-size: 13.5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.conv-snippet { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; margin-top: 2px; }
.unread-dot { background: var(--tfc-orange); color: #fff; font-size: 10.5px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; padding: 0 5px; }
.chan-tag { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
  padding: 1px 6px; border-radius: 10px; background: #eef1f6; color: var(--tfc-navy); }
.chan-tag.sms { background: #e4effd; color: #1d5fb0; }
.chan-tag.whatsapp { background: #e3f6e9; color: #1a7f44; }
.chan-tag.call { background: #efe8fd; color: #6a3fb0; }
.chan-tag.note { background: #f1f1f4; color: #6a6f7a; }
.chan-tag.email { background: #fdeee4; color: #a8501a; }
.chan-tag.chat { background: #e6f4f7; color: #1f6f80; }
.inbox-thread { display: flex; flex-direction: column; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: 12px; padding: 13px 18px;
  border-bottom: 1px solid var(--line); }
.thread-name a { color: var(--tfc-navy); font-weight: 700; text-decoration: none; font-size: 15px; }
.thread-sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.thread-body { flex: 1; overflow-y: auto; padding: 18px; background: #f7f9fc; min-height: 0; }
.bubble-row { display: flex; margin-bottom: 12px; }
.bubble-row.out { justify-content: flex-end; }
.bubble { max-width: 70%; padding: 9px 13px; border-radius: 14px; }
.bubble-row.in .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble-row.out .bubble { background: linear-gradient(135deg, var(--tfc-orange), var(--tfc-amber));
  color: #fff; border-bottom-right-radius: 4px; }
.bubble-body { font-size: 13.5px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.bubble-meta { font-size: 10.5px; margin-top: 5px; opacity: .8; }
.bubble-row.out .bubble-meta .chan-tag { background: rgba(255,255,255,.25); color: #fff; }
.bubble-subject { font-weight: 700; font-size: 13.5px; margin-bottom: 3px; }

/* Long messages (mostly imported emails): preview with a show-more toggle. */
.msg-long > summary { list-style: none; cursor: pointer; }
.msg-long > summary::-webkit-details-marker { display: none; }
.msg-long[open] > summary .bubble-body, .msg-long[open] > summary .msg-body { display: none; }
.msg-more { display: block; margin-top: 4px; font-size: 11.5px; font-weight: 600; text-decoration: underline; }
.msg-more::after { content: "Show full message"; }
.msg-long[open] .msg-more::after { content: "Show less"; }
.composer { border-top: 1px solid var(--line); padding: 12px 14px; background: #fff; }
.composer-row { display: flex; gap: 9px; align-items: flex-end; }
.chan-select { font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 9px 8px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.composer textarea { flex: 1; resize: none; font-family: inherit; font-size: 13.5px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px; max-height: 120px; }
.thread-empty { flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--muted); text-align: center; }
.thread-empty-icon { font-size: 34px; margin-bottom: 8px; }
.empty-note { color: var(--muted); font-size: 13px; padding: 16px; }
.conv-items .ta-item { padding: 9px 12px; }

/* ---- Opportunity detail ------------------------------------------------- */
.fld { display: block; font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.fld input, .fld select, .fld textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 13.5px;
  color: var(--text); background: #fff; box-sizing: border-box; resize: vertical; }
.fld .typeahead { margin-top: 4px; }
.fld .typeahead input { margin-top: 0; }
.save-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.save-msg { font-size: 12.5px; font-weight: 600; }
.save-msg.ok { color: #1a7f44; }
.save-msg.err { color: #c0392b; }
.ostat { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; text-transform: capitalize; }
.ostat.open { background: #e4effd; color: #1d5fb0; }
.ostat.won { background: #e5f6ec; color: #1a7f44; }
.ostat.lost { background: #f1f1f4; color: #6a6f7a; }
.ostat.abandoned { background: #fff4d9; color: #9a6b00; }
.note-add { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 12px; }
.note-add textarea { flex: 1; resize: vertical; font-family: inherit; font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; }
.note { border-left: 3px solid var(--tfc-amber); background: #fafbfd; padding: 9px 12px;
  border-radius: 0 8px 8px 0; margin-bottom: 9px; }
.note-body { font-size: 13.5px; color: var(--text); white-space: pre-wrap; }
.note-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.card-name { color: var(--tfc-navy); text-decoration: none; font-weight: 600; }
.card-name:hover { text-decoration: underline; }
.opp-table td a { color: var(--tfc-navy); text-decoration: none; }
.opp-table td a:hover { text-decoration: underline; }

/* ---- Calendar ----------------------------------------------------------- */
.week-label { color: var(--muted); font-size: 12.5px; margin-left: 12px; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 4px; }
.day-col { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column; min-height: 320px; }
.day-col.is-today { border-color: var(--tfc-orange); box-shadow: 0 0 0 1px var(--tfc-orange); }
.day-head { display: flex; align-items: baseline; justify-content: space-between; padding: 8px 10px;
  border-bottom: 1px solid var(--line); background: #fafbfd; }
.day-col.is-today .day-head { background: #fff6f1; }
.day-name { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; }
.day-num { font-size: 15px; font-weight: 700; color: var(--tfc-navy); }
.day-body { padding: 7px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.appt { text-align: left; border: 0; border-left: 3px solid var(--tfc-navy); background: #eef2f9;
  border-radius: 0 7px 7px 0; padding: 6px 8px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; gap: 1px; width: 100%; }
.appt:hover { filter: brightness(0.97); }
.appt.booked { border-left-color: #1d5fb0; background: #e8f0fb; }
.appt.completed { border-left-color: #1a7f44; background: #e8f6ee; }
.appt.cancelled { border-left-color: #9aa0ab; background: #f1f1f4; opacity: .7; text-decoration: line-through; }
.appt.no_show { border-left-color: #b4600f; background: #fdf0e2; }
.appt.external { border-left-color: #8a94a6; background: #f4f6f9; cursor: pointer;
  border-left-style: dashed; text-decoration: none; }
.appt.external:hover { filter: brightness(0.97); background: #eef1f6; }
.appt.external .appt-title { font-weight: 500; color: var(--muted); }

/* Appointment modal: sits above the opportunity modal; anchor its close button */
.appt-modal-overlay { z-index: 70; }
.appt-modal-overlay .modal { position: relative; }
/* Make the `hidden` attribute win over `.modal label { display:block }` so
   conditionally-shown fields (status, location detail) actually hide. */
.modal [hidden] { display: none !important; }

/* Guests */
.guest-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.guest-chip { display: inline-flex; align-items: center; gap: 6px; background: #eef2f9;
  border: 1px solid var(--line); border-radius: 20px; padding: 3px 6px 3px 11px; font-size: 12px; }
.guest-x { border: none; background: transparent; cursor: pointer; font-size: 15px;
  line-height: 1; color: var(--muted); padding: 0 2px; }
.guest-x:hover { color: #c0392b; }
.new-guest { margin: 8px 0; padding: 10px; background: #f6f8fb; border-radius: 8px; }
.new-guest input { margin-bottom: 0; }

/* Per-staff meeting links (Calendar settings) */
.cs-links { display: flex; flex-direction: column; gap: 4px; }
.cs-links input { width: 210px; }

/* Calendar group member picker */
.grp-members { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 4px; }
.grp-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  background: #f6f8fb; border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px; cursor: pointer; }
.appt-time { font-size: 11px; font-weight: 700; color: var(--tfc-navy); }
.appt-title { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.25; }
.appt-who { font-size: 11px; color: var(--muted); }
.appt-assignee { font-size: 10px; color: var(--tfc-orange); font-weight: 700; }

@media (max-width: 1000px) {
  .week-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Settings ----------------------------------------------------------- */
.pipe-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.pipe-picker .seg-item { border: 1px solid var(--line); border-radius: 8px; }
.st-name { width: 100%; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px;
  font-family: inherit; font-size: 13px; }
.st-prob { width: 90px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px;
  font-family: inherit; font-size: 13px; text-align: right; }
.st-name.saved, .st-prob.saved { border-color: #1a7f44; box-shadow: 0 0 0 2px #e5f6ec; }
.st-name.saving, .st-prob.saving { opacity: .6; }
.int-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.int-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex;
  flex-direction: column; gap: 7px; align-items: flex-start; }
.int-name { font-weight: 700; color: var(--tfc-navy); font-size: 13.5px; }
.int-sub { color: var(--muted); font-size: 11.5px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 64px 1fr; }
  .brand-text, .nav-item span:not(.nav-ico):not(.soon), .sidebar-foot, .nav-item .soon { display: none; }
  .kpis { flex-wrap: wrap; }
}

/* ============================================================
   Opportunity modal (global, opened from any list)
   ============================================================ */
body.modal-open { overflow: hidden; }
.opp-modal-overlay { align-items: flex-start; }
.opp-modal {
  position: relative; width: 980px; max-width: 94vw;
  max-height: 88vh; margin-top: 5vh; padding: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.opp-modal-body { overflow-y: auto; padding: 22px 24px 26px; }
.modal-x {
  position: absolute; top: 12px; right: 14px; z-index: 2;
  border: none; background: transparent; font-size: 24px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.modal-x:hover { background: #f1f5fb; color: var(--tfc-navy); }
.modal-loading { padding: 40px; text-align: center; color: var(--muted); }

.opp-edit-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; padding-right: 34px; border-bottom: 1px solid var(--line);
  padding-bottom: 14px; margin-bottom: 4px;
}
.opp-edit-title { display: flex; gap: 12px; align-items: center; }
.opp-edit-title h2 { margin: 0; font-size: 18px; color: var(--tfc-navy); }
.opp-edit-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.opp-edit-chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.contact-jump { text-decoration: none; font-weight: 700; color: var(--tfc-gold); margin-left: 4px; }

/* ============================================================
   Contact page: 3-column with conversation timeline
   ============================================================ */
.contact-grid {
  display: grid; grid-template-columns: 300px minmax(0, 1fr) 300px;
  gap: 18px; margin-top: 16px; align-items: start;
}
.conv-panel { display: flex; flex-direction: column; min-height: 420px; max-height: 76vh; }
.conv-head { display: flex; align-items: baseline; gap: 10px; }
.conv-head h3 { margin: 0; }
.conv-stream {
  flex: 1; overflow-y: auto; margin: 12px -4px; padding: 4px 6px;
  display: flex; flex-direction: column; gap: 12px;
}
.conv-earlier, .conv-empty { text-align: center; color: var(--muted); font-size: 12px; padding: 6px; }

.msg { display: flex; flex-direction: column; max-width: 78%; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.in { align-self: flex-start; align-items: flex-start; }
.msg-bubble { padding: 9px 12px; border-radius: 12px; font-size: 13.5px; }
.msg.out .msg-bubble { background: #e4effd; border-bottom-right-radius: 3px; }
.msg.in .msg-bubble { background: #f3f5f8; border-bottom-left-radius: 3px; }
.msg-body { white-space: pre-wrap; margin-top: 3px; color: var(--text); }
.msg-meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; }

.act-note { align-self: stretch; background: #fffdf4; border-left: 3px solid var(--tfc-gold);
  border-radius: 6px; padding: 9px 12px; }
.act-note-body { font-size: 13.5px; white-space: pre-wrap; color: var(--text); margin-top: 3px; }

.chan-badge { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; padding: 2px 7px; border-radius: 20px; }
.chan-badge.sms { background: #e4effd; color: #1d5fb0; }
.chan-badge.whatsapp { background: #e5f6ec; color: #1a7f44; }
.chan-badge.call { background: #efe9fb; color: #5b3fb0; }
.chan-badge.note { background: #fff4d9; color: #9a6b00; }
.chan-badge.email { background: #fdeee4; color: #a8501a; }
.chan-badge.chat { background: #e6f4f7; color: #1f6f80; }
.msg-subject { font-weight: 700; margin-top: 4px; color: var(--text); }

.composer { display: flex; gap: 8px; align-items: flex-start; border-top: 1px solid var(--line); padding-top: 12px; }
.composer select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 12.5px; }
.composer textarea { flex: 1; resize: vertical; font-family: inherit; font-size: 13.5px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; }

.opp-card-link { display: block; text-decoration: none; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; color: inherit; transition: border-color .12s, box-shadow .12s; }
.opp-card-link:hover { border-color: var(--tfc-gold); box-shadow: 0 2px 8px rgba(11,42,74,.08); }
.opp-card-name { font-weight: 700; color: var(--tfc-navy); font-size: 13.5px; }
.opp-card-meta { font-size: 11.5px; color: var(--muted); margin: 3px 0 7px; }
.opp-card-foot { display: flex; justify-content: space-between; align-items: center; }
.opp-card-value { font-weight: 700; font-size: 13px; }

@media (max-width: 1100px) {
  .contact-grid { grid-template-columns: 1fr; }
  .conv-panel { max-height: none; }
}

/* ============================================================
   Opportunity: document upload field + next action
   ============================================================ */
.doc-field { margin: 4px 0 12px; }
.doc-field-label { font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.doc-area { margin-bottom: 7px; }
.doc-empty { font-size: 12.5px; color: var(--muted); }
.doc-file { display: flex; align-items: center; gap: 8px; background: #f6f8fb;
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.doc-file a { text-decoration: none; color: var(--tfc-navy); font-weight: 600; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-size { color: var(--muted); font-size: 11px; margin-left: auto; white-space: nowrap; }
.doc-remove { border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 17px; line-height: 1; padding: 0 2px; }
.doc-remove:hover { color: #c0392b; }
.doc-upload { display: inline-block; cursor: pointer; }
.doc-msg { font-size: 12px; font-weight: 600; margin-left: 8px; }
.doc-msg.ok { color: #1a7f44; }
.doc-msg.err { color: #c0392b; }

.card-next { font-size: 11.5px; color: #9a6b00; background: #fff7e6; border-radius: 5px;
  padding: 2px 7px; margin: 6px 0 2px; display: inline-block; }
.next-date { font-weight: 600; font-size: 12.5px; color: var(--tfc-navy); }

.btn-ghost.danger { color: #c0392b; border-color: #e9c3bd; }
.btn-ghost.danger:hover { background: #fdecea; }

/* ============================================================
   Templates: merge fields, preview, composer picker
   ============================================================ */
.merge-wrap { display: flex; flex-wrap: wrap; gap: 7px; }
.merge-chip { border: 1px solid var(--line); background: #f6f8fb; color: var(--tfc-navy);
  border-radius: 6px; padding: 5px 9px; font-size: 12px; font-family: ui-monospace, monospace;
  cursor: pointer; }
.merge-chip:hover { border-color: var(--tfc-gold); background: #fff7e6; }
.tpl-preview { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px; font-size: 13.5px; color: var(--text); min-height: 90px; }
.tpl-edit textarea { font-family: inherit; }

.composer { position: relative; }
.tpl-picker { position: absolute; bottom: calc(100% + 8px); left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 34px rgba(11,42,74,.16); max-height: 300px; overflow-y: auto; }
.tpl-picker[hidden] { display: none; }
.tpl-pick-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #eef1f5; }
.tpl-pick-item:last-child { border-bottom: none; }
.tpl-pick-item:hover { background: #f1f5fb; }
.tpl-pick-name { font-weight: 600; font-size: 13px; color: var(--tfc-navy); }
.tpl-pick-prev { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; margin-top: 2px; }
.tpl-pick-note { padding: 14px; color: var(--muted); font-size: 13px; }
