/* CBG CRM — Lightning-shaped: dense, square-ish, 1px borders, no decoration
   that isn't doing a job. */
:root {
  /* Application chrome — deep, so the app has an anchor and the content reads
     as raised out of it. Everything below the chrome stays light. */
  --chrome:       #0b2545;
  --chrome-2:     #163963;
  --chrome-text:  #ffffff;
  --chrome-dim:   rgba(255,255,255,.72);
  --panel-head:   #0b2545;
  --panel-text:   #ffffff;

  /* Blue is reserved for action and for data. */
  --brand:        #1b96ff;
  --brand-dark:   #0176d3;
  --brand-darker: #014486;
  --brand-tint:   #eef6ff;
  --brand-tint-2: #d3e8ff;
  --bubble-out:   #0176d3;

  --bg:        #eef1f6;
  --surface:   #ffffff;
  --surface-2: #f7f9fc;
  --border:    #cfd8e3;
  --border-2:  #e7ecf3;

  --text:      #10203a;
  --text-weak: #5a6b82;
  --text-inv:  #ffffff;

  --success: #17845b; --success-bg: #e6f6ef;
  --warning: #9a5b00; --warning-bg: #fff4e5;
  --error:   #c0223b; --error-bg:   #fdeaed;

  /* One elevation scale, used consistently. */
  --shadow-1: 0 1px 2px rgba(16,32,58,.05), 0 1px 3px rgba(16,32,58,.07);
  --shadow-2: 0 2px 6px rgba(16,32,58,.06), 0 6px 16px rgba(16,32,58,.08);
  --shadow-3: 0 10px 34px rgba(16,32,58,.18);
  --shadow: var(--shadow-2);

  --r: 10px;
  --r-sm: 7px;
  --nav-w: 248px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 13px; line-height: 1.45;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1,h2,h3,h4 { margin: 0; font-weight: 600; }

/* ------------------------------------------------------------- app frame */
.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 12px; height: 50px; flex: 0 0 50px;
  padding: 0 14px; background: var(--chrome); color: var(--chrome-text); z-index: 40;
  box-shadow: 0 1px 0 rgba(255,255,255,.06), var(--shadow-1);
}
/* The original artwork has a white background — kept as supplied, not made
   transparent. */
.topbar .logo { height: 34px; display: block; }
.topbar .logoplate { background: #fff; padding: 4px 7px; border-radius: var(--r-sm);
  display: flex; box-shadow: var(--shadow-1); }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: 0; border-radius: var(--r);
  background: transparent; color: inherit; cursor: pointer;
}
.iconbtn:hover { background: rgba(255,255,255,.14); }
.iconbtn svg { width: 18px; height: 18px; }

.globalsearch { flex: 1 1 auto; max-width: 520px; position: relative; }
.globalsearch input {
  width: 100%; height: 34px; padding: 0 10px 0 34px; border: 1px solid transparent;
  border-radius: var(--r-sm); background: rgba(255,255,255,.12); color: #fff;
  transition: background .12s;
}
.globalsearch input::placeholder { color: var(--chrome-dim); }
.globalsearch input:focus { outline: 0; background: #fff; color: var(--text);
  box-shadow: 0 0 0 3px rgba(27,150,255,.35); }
.globalsearch input:focus::placeholder { color: var(--text-weak); }
.globalsearch input:focus::placeholder { color: var(--text-weak); }
.globalsearch .gs-icon {
  position: absolute; left: 9px; top: 8px; width: 16px; height: 16px; opacity: .8; pointer-events: none;
}
.globalsearch input:focus + .gs-icon { opacity: .5; }
.gs-results {
  position: absolute; top: 36px; left: 0; right: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow);
  max-height: 60vh; overflow: auto; color: var(--text); z-index: 60;
}
.gs-group { padding: 6px 12px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-weak); background: var(--surface-2); }
.gs-item { display: block; padding: 7px 12px; border-bottom: 1px solid var(--border-2); cursor: pointer; }
.gs-item:hover, .gs-item.active { background: var(--brand-tint); text-decoration: none; }
.gs-item small { color: var(--text-weak); display: block; }

.userbtn { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  border: 0; background: transparent; color: inherit; cursor: pointer; border-radius: var(--r); }
.userbtn:hover { background: rgba(255,255,255,.14); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 600; flex: none;
}
/* On the blue chrome the brand-coloured avatar disappears into the bar. */
.topbar .avatar { background: var(--brand); color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.18); }
.usermenu {
  position: absolute; top: 46px; right: 8px; width: 260px; background: var(--surface);
  color: var(--text); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow); z-index: 60; overflow: hidden;
}
.usermenu .um-head { padding: 12px; border-bottom: 1px solid var(--border-2); }
.usermenu .um-head b { display: block; }
.usermenu .um-head span { color: var(--text-weak); }
.usermenu button {
  display: block; width: 100%; text-align: left; padding: 9px 12px;
  border: 0; background: transparent; cursor: pointer;
}
.usermenu button:hover { background: var(--brand-tint); }

.body { display: flex; flex: 1; min-height: 0; position: relative; }

/* ------------------------------------------------------------------- nav */
/* Collapsed is an icon rail, not nothing — the destinations stay reachable
   without giving up the width. */
:root { --nav-rail: 52px; }
.nav {
  width: var(--nav-rail); flex: 0 0 var(--nav-rail);
  background: var(--surface); border-right: 1px solid var(--border-2);
  overflow-x: hidden; overflow-y: auto; padding: 8px 0;
  transition: width .14s ease, flex-basis .14s ease;
}
.nav.open { width: var(--nav-w); flex-basis: var(--nav-w); }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 0 10px 16px;
  color: var(--text); border-left: 3px solid transparent; font-weight: 500;
  white-space: nowrap; overflow: hidden;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--brand-tint); border-left-color: var(--brand); color: var(--brand-dark); }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav a.active svg { opacity: 1; }
.nav .nav-label { opacity: 0; transition: opacity .1s; }
.nav.open .nav-label { opacity: 1; }
.nav .nav-section {
  padding: 12px 16px 4px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-weak); white-space: nowrap; overflow: hidden;
  opacity: 0; height: 0; padding-top: 0; padding-bottom: 0;
}
.nav.open .nav-section { opacity: 1; height: auto; padding: 12px 16px 4px; }
.scrim { display: none; }

@media (max-width: 900px) {
  /* On a phone the rail costs too much, so it floats over the content instead. */
  .nav {
    position: absolute; top: 0; bottom: 0; left: 0; z-index: 30;
    width: var(--nav-w); flex-basis: 0; transform: translateX(-100%);
    box-shadow: var(--shadow); transition: transform .16s ease;
  }
  .nav.open { transform: none; }
  .nav .nav-label, .nav .nav-section { opacity: 1; }
  .nav .nav-section { height: auto; padding: 12px 16px 4px; }
  .scrim { position: absolute; inset: 0; background: rgba(0,0,0,.28); z-index: 25; }
}

/* ------------------------------------------------------------ console tabs */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tabs {
  display: flex; align-items: stretch; gap: 1px; background: var(--surface);
  border-bottom: 1px solid var(--border-2); overflow-x: auto; flex: 0 0 auto;
}
.tab {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 38px;
  border: 0; border-bottom: 2px solid transparent; background: transparent;
  cursor: pointer; white-space: nowrap; color: var(--text-weak); max-width: 260px;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { border-bottom-color: var(--brand); color: var(--chrome); font-weight: 650; }
.tab .tab-label { overflow: hidden; text-overflow: ellipsis; }
.tab .tab-close {
  width: 18px; height: 18px; border-radius: 50%; border: 0; background: transparent;
  color: inherit; cursor: pointer; line-height: 1; flex: none;
}
.tab .tab-close:hover { background: var(--border-2); }
.view { flex: 1; min-height: 0; overflow: auto; }

/* ------------------------------------------------------------- primitives */
.page { padding: 14px; }
.pagehead { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.pagehead .grow { flex: 1; min-width: 200px; }
.pagehead h1 { font-size: 25px; font-weight: 680; letter-spacing: -.02em; }
.pagehead .sub { color: var(--text-weak); font-size: 13.5px; margin-top: 2px; }

.card { background: var(--surface); border: 1px solid rgba(16,32,58,.05);
  border-radius: var(--r); box-shadow: var(--shadow-1); overflow: hidden;
  transition: box-shadow .14s; }
.card:hover { box-shadow: var(--shadow-2); }
.card + .card { margin-top: 14px; }
.card > header {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border-2); font-weight: 650; font-size: 14px;
  letter-spacing: -.01em;
}
.card > header .grow { flex: 1; }
.card .body { padding: 16px; display: block; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface);
  color: var(--brand-dark); font-weight: 600; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-1); transition: background .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #2ba0ff, #0d86ef);
  border-color: #0d86ef; color: #fff; box-shadow: 0 1px 2px rgba(13,134,239,.4); }
.btn.primary:hover { background: linear-gradient(180deg, #1b96ff, #0176d3); }
.btn.subtle { color: var(--text); border-color: transparent; }
.btn.subtle:hover { background: var(--border-2); }
.btn.danger { color: var(--error); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn svg { width: 14px; height: 14px; }

.field { margin-bottom: 12px; }
.field > label { display: block; margin-bottom: 3px; color: var(--text-weak); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; min-height: 32px; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--surface);
}
.input:focus, .select:focus, .textarea:focus {
  outline: 0; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand);
}
.textarea { min-height: 76px; resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.checkline { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.checkline input { margin: 0; }

table.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
table.grid th, table.grid td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border-2);
  vertical-align: top;
}
table.grid th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-weak);
  background: var(--surface-2); font-weight: 700; white-space: nowrap; position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--border-2); padding-top: 10px; padding-bottom: 10px;
}
table.grid th.sortable { cursor: pointer; user-select: none; }
table.grid th.sortable:hover { color: var(--brand); }
table.grid tbody tr { transition: background .1s; }
table.grid tbody tr:hover { background: var(--brand-tint); }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow: auto; border: 1px solid rgba(16,32,58,.05); border-radius: var(--r);
  background: var(--surface); box-shadow: var(--shadow-1); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px;
  font-weight: 650; border: 1px solid var(--border); background: var(--surface-2);
  white-space: nowrap; letter-spacing: .01em;
}
.badge.blue   { background: var(--brand-tint); border-color: var(--brand-tint-2); color: var(--brand-dark); }
.badge.green  { background: var(--success-bg); border-color: #a9dab7; color: var(--success); }
.badge.amber  { background: var(--warning-bg); border-color: #f5d3a0; color: var(--warning); }
.badge.red    { background: var(--error-bg);   border-color: #f5b8b0; color: var(--error); }
.badge.grey   { color: var(--text-weak); }

.muted { color: var(--text-weak); }
.tiny { font-size: 11px; }
.mono { font-variant-numeric: tabular-nums; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-weak); }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border-2); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; }

/* ------------------------------------------------------- inline messaging */
/* No browser dialogs anywhere — messages appear in the page. */
.toasts { position: fixed; top: 60px; right: 14px; z-index: 200; display: grid; gap: 8px; width: 340px; }
.toast {
  display: flex; gap: 9px; padding: 10px 12px; border-radius: var(--r);
  background: var(--surface); border-left: 4px solid var(--brand); box-shadow: var(--shadow);
  animation: slidein .18s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--error); }
.toast .grow { flex: 1; }
.toast button { border: 0; background: transparent; cursor: pointer; color: var(--text-weak); }
@keyframes slidein { from { transform: translateX(16px); opacity: 0; } }

.inline-msg {
  display: flex; gap: 8px; padding: 9px 12px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 12px;
}
.inline-msg.warn  { background: var(--warning-bg); border-color: #f5d3a0; }
.inline-msg.error { background: var(--error-bg);   border-color: #f5b8b0; }
.inline-msg.info  { background: var(--brand-tint); border-color: var(--brand-tint-2); }
.inline-msg .grow { flex: 1; }

/* confirm strip replaces window.confirm */
.confirm {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--warning-bg); border: 1px solid #f5d3a0; border-radius: var(--r); margin-bottom: 12px;
}
.confirm .grow { flex: 1; }

/* drawer replaces modal dialogs for forms */
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 90; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--surface); z-index: 100; display: flex; flex-direction: column;
  box-shadow: -2px 0 12px rgba(0,0,0,.18); animation: drawerin .18s ease;
}
@keyframes drawerin { from { transform: translateX(20px); opacity: .6; } }
.drawer > header {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border-2); font-weight: 600; font-size: 15px;
}
.drawer > header .grow { flex: 1; }
.drawer .drawer-body { flex: 1; overflow: auto; padding: 16px; }
.drawer > footer {
  display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border-2); background: var(--surface-2);
}

/* -------------------------------------------------------------- pipeline */
/* Salesforce-shaped path: every step is an arrow with a notch cut into its left
   edge and a point on its right, and the steps overlap so they interlock. */
.pipeline { display: flex; overflow-x: auto; padding: 0; margin-bottom: 10px; }
.chev {
  --notch: 15px;
  position: relative; flex: 1 1 0; min-width: 128px; height: 44px;
  padding: 0 12px 0 calc(var(--notch) + 16px);
  display: flex; flex-direction: column; justify-content: center;
  border: 0; cursor: pointer; text-align: left; white-space: nowrap;
  background: #e9eef3; color: var(--text-weak); font-weight: 600; font-size: 13px;
  margin-right: -12px;
  clip-path: polygon(0 0, calc(100% - var(--notch)) 0, 100% 50%,
                     calc(100% - var(--notch)) 100%, 0 100%, var(--notch) 50%);
  transition: background .12s, color .12s;
}
.chev:first-child {
  padding-left: 16px;
  clip-path: polygon(0 0, calc(100% - var(--notch)) 0, 100% 50%,
                     calc(100% - var(--notch)) 100%, 0 100%);
}
.chev:last-child {
  margin-right: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, var(--notch) 50%);
}
.chev:only-child { clip-path: none; }
.chev .chev-label { display: block; line-height: 1.15; }
.chev .chev-when { display: block; font-weight: 400; font-size: 10.5px; opacity: .8; line-height: 1.2; }

.chev.done    { background: #c7e2f7; color: #04395e; }
.chev.current { background: var(--brand); color: #fff; }
.chev.won     { background: var(--success); color: #fff; }
.chev.lost    { background: #6b7684; color: #fff; }
.chev:not(:disabled):hover { filter: brightness(.95); }
.chev:disabled { cursor: default; }
.chev:focus-visible { outline: 2px solid var(--brand-dark); outline-offset: -3px; }

/* ----------------------------------------------------------- record view */
/* Three columns: activity left, the record itself in the middle where it has
   room to breathe, the conversation on the right. */
.record { display: grid; grid-template-columns: 300px minmax(0, 1fr) 370px;
  gap: 12px; align-items: start; }
.record > .col { display: grid; gap: 14px; min-width: 0; }

/* Two columns, for records that do not have a conversation to put on the right.
   Documents and activity sit left; the record itself takes the rest. */
.record2 { display: grid; grid-template-columns: 340px minmax(0, 1fr);
  gap: 12px; align-items: start; }
.record2 > .col { display: grid; gap: 14px; min-width: 0; }
@media (max-width: 900px) { .record2 { grid-template-columns: 1fr; } }
.record .rail { display: grid; gap: 14px; }
.recordhead {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r);
  padding: 10px 14px; margin-bottom: 10px;
}
.recordhead .eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-weak); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.recordhead .eyebrow .sep { opacity: .45; }
/* click-to-dial marker beside a number */
.dialicon { display: inline-flex; vertical-align: -2px; margin-left: 5px; color: var(--success); }
.dialicon svg { width: 13px; height: 13px; }
.recordhead h1 { font-size: 23px; font-weight: 680; letter-spacing: -.02em; margin: 1px 0 0; }
.recordhead .facts { display: flex; flex-wrap: wrap; gap: 4px 24px; margin-top: 7px; }
.recordhead .facts div { min-width: 130px; }
.recordhead .facts .k { font-size: 11px; color: var(--text-weak); }

.detailgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 20px; }
.detailgrid .k { font-size: 11px; color: var(--text-weak); }
.detailgrid .v { word-break: break-word; }
.detailgrid .v.long { white-space: pre-wrap; }

/* activity rail */
.act-composer { border-bottom: 1px solid var(--border-2); padding: 12px 14px; }
.act-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.act-tabs button {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--r);
  padding: 3px 10px; cursor: pointer; font-size: 12px; color: var(--text-weak);
}
.act-tabs button.active { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
.note-editor {
  min-height: 130px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); overflow-y: auto; line-height: 1.6; font-size: 13px;
}
.note-editor:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.note-editor:empty::before { content: attr(data-placeholder); color: var(--text-weak); }
.note-editor ul, .note-editor ol { margin: 6px 0; padding-left: 22px; }
.note-toolbar { display: flex; gap: 2px; padding: 4px; border: 1px solid var(--border);
  border-bottom: 0; border-radius: var(--r) var(--r) 0 0; background: var(--surface-2); }
.note-toolbar + .note-editor { border-radius: 0 0 var(--r) var(--r); }
.note-toolbar button {
  width: 27px; height: 25px; border: 0; background: transparent; cursor: pointer;
  border-radius: 3px; color: var(--text-weak);
}
.note-toolbar button:hover { background: var(--border-2); color: var(--text); }

.timeline { padding: 6px 0; }
.tl-item { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border-2); }
.tl-item:last-child { border-bottom: 0; }
.tl-icon {
  width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand-dark);
}
.tl-icon svg { width: 14px; height: 14px; }
.tl-icon.note   { background: #fef5e7; color: #a86403; }
.tl-icon.system { background: var(--surface-2); color: var(--text-weak); }
.tl-icon.email  { background: var(--brand-tint); color: var(--brand-dark); }
.tl-body { flex: 1; min-width: 0; }
.tl-body .tl-head { display: flex; gap: 8px; align-items: baseline; }
.tl-body .tl-head b { font-size: 13px; }
.tl-body .tl-when { margin-left: auto; color: var(--text-weak); font-size: 11px; white-space: nowrap; }
.tl-content { margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.tl-content.rich { white-space: normal; }
.tl-content.rich ul, .tl-content.rich ol { margin: 4px 0; padding-left: 20px; }

/* ------------------------------------------------------------- dashboard */
.widgets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; align-items: start; }
.widget { grid-column: span 3; }
.widget.third { grid-column: span 2; }
.widget.half  { grid-column: span 3; }
.widget.full  { grid-column: span 6; }
.widget .body:has(.metric) { padding: 18px 16px 20px; }
.metric { font-size: 44px; font-weight: 660; line-height: 1; letter-spacing: -.035em;
  color: var(--chrome); font-variant-numeric: tabular-nums; }
.metric-sub { color: var(--text-weak); font-size: 12.5px; margin-top: 6px; }

.barrow { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; gap: 12px;
  align-items: center; margin-bottom: 12px; font-size: 13px; }
.barrow .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bartrack { background: #eaeff6; border-radius: 20px; height: 10px; overflow: hidden; }
.barfill { background: linear-gradient(90deg, #0176d3, #1b96ff); height: 100%;
  border-radius: 20px; min-width: 4px; transition: width .5s cubic-bezier(.2,.7,.3,1); }
.barrow .val { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 650; }

.donut-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.legend { display: grid; gap: 5px; flex: 1; min-width: 140px; }
.legend div { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend i { width: 10px; height: 10px; border-radius: 2px; flex: none; }

/* --------------------------------------------------------------- filters */
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filterbar .searchbox { position: relative; min-width: 230px; flex: 1; max-width: 380px; }
.filterbar .searchbox input { padding-left: 30px; }
.filterbar .searchbox svg { position: absolute; left: 9px; top: 9px; width: 15px; height: 15px;
  opacity: .5; pointer-events: none; }
.chipfilter {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px;
  border: 1px solid var(--brand-tint-2); background: var(--brand-tint);
  border-radius: 14px; color: var(--brand-dark); font-size: 12px;
}
.chipfilter button { border: 0; background: transparent; cursor: pointer; color: inherit; padding: 0 2px; }

.pager { display: flex; align-items: center; gap: 10px; padding: 9px 4px; flex-wrap: wrap; }
.pager .grow { flex: 1; }

.subnav { display: flex; gap: 2px; border-bottom: 1px solid var(--border-2); margin-bottom: 14px;
  overflow-x: auto; }
.subnav button {
  border: 0; background: transparent; padding: 8px 13px; cursor: pointer;
  border-bottom: 2px solid transparent; color: var(--text-weak); white-space: nowrap; font-weight: 500;
}
.subnav button.active { border-bottom-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
.subnav button:hover { color: var(--text); }

/* ----------------------------------------------------------------- login */
.loginpage {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% 10%, #163963 0%, #0b2545 55%, #071a33 100%);
}
.loginbox { width: 100%; max-width: 396px; background: var(--surface);
  border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.42); padding: 30px; }
.loginbox .brand { display: block; height: 62px; margin: 0 auto 20px; border-radius: 4px; }
.loginbox h1 { font-size: 17px; margin-bottom: 4px; }
.loginbox .btn { width: 100%; justify-content: center; height: 36px; }
.linkline { margin-top: 14px; text-align: center; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 1120px) {
  .record { grid-template-columns: minmax(0, 1fr) 360px; }
  .record > .col:first-child { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .record { grid-template-columns: 1fr; }
  .record > .col:first-child { grid-column: auto; }
  .record .rail { order: 2; }
  .widgets { grid-template-columns: repeat(2, 1fr); }
  .widget, .widget.third, .widget.half { grid-column: span 1; }
  .widget.full { grid-column: span 2; }
}
@media (max-width: 640px) {
  .page { padding: 11px; }
  .topbar { gap: 6px; padding: 0 6px; }
  .topbar .logo { height: 24px; }
  .globalsearch { min-width: 0; }
  .userbtn .uname { display: none; }
  .widgets { grid-template-columns: 1fr; }
  .widget, .widget.third, .widget.half, .widget.full { grid-column: span 1; }
  .toasts { left: 10px; right: 10px; width: auto; }
  .detailgrid { grid-template-columns: 1fr; }
  .recordhead h1 { font-size: 18px; }
  .drawer { width: 100%; }
}

/* ==========================================================================
   Phone + SMS. The footer carries two buttons and nothing else; the dialer is
   a panel on the left where the whole call is handled, and SMS docks right.
   ========================================================================== */

:root { --footer-h: 44px; --dock-w: 380px; --dialer-w: 312px; }
.app.has-softphone .body { padding-bottom: var(--footer-h); }

.softbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--footer-h); z-index: 70;
  display: flex; align-items: center; gap: 8px; padding: 0 10px;
  background: var(--chrome); color: var(--chrome-text);
  box-shadow: 0 -2px 14px rgba(16,32,58,.22);
}
.softbar > * { flex: none; }
.softbar .grow { flex: 1; }
.softbar .sb-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 31px; padding: 0 14px;
  border: 1px solid rgba(255,255,255,.2); border-radius: var(--r-sm);
  background: rgba(255,255,255,.1); color: #fff; cursor: pointer; font-weight: 600;
  transition: background .12s;
}
.softbar .sb-btn:hover { background: rgba(255,255,255,.2); }
.softbar .sb-btn.on { background: var(--brand); color: #fff; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(27,150,255,.25); }
.softbar .sb-btn svg { width: 15px; height: 15px; }
.softbar .sb-status { display: flex; align-items: center; gap: 7px; font-size: 12px; white-space: nowrap; }
.softbar .dot { width: 8px; height: 8px; border-radius: 50%; background: #7d8b98; flex: none; }
.softbar .dot.ready { background: #2ecc71; }
.softbar .dot.busy  { background: #fe9339; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.softbar .sb-unread {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--error);
  color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.testchip {
  padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap;
  background: rgba(255,183,77,.16); border: 1px solid rgba(255,183,77,.4); color: #ffcf8f;
}

/* ---------------------------------------------- panels above the bar item */
/* A footer bar is a launcher for panels, not a cramped control surface.
   Each panel is anchored to the button that opened it and is a fixed width,
   so nothing moves or resizes when you switch panels or tabs. */
.tpanel {
  position: fixed; z-index: 85; background: var(--surface); overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 -6px 26px rgba(0,0,0,.22);
}
/* Phone: anchored above its bar item, and a FIXED height — otherwise each tab
   sizes the panel to its own content and the whole thing jumps as you switch. */
.tpanel.phone {
  bottom: var(--footer-h); width: 470px; max-width: calc(100vw - 16px);
  height: min(560px, calc(100vh - var(--footer-h) - 64px));
  border-radius: 8px 8px 0 0;
}
/* Messages: docked down the right-hand edge. */
.tpanel.right {
  top: 50px; right: 0; bottom: var(--footer-h); left: auto;
  width: 400px; max-width: 100vw; height: auto; border-radius: 0;
  border-left: 1px solid var(--border);
  box-shadow: -2px 0 14px rgba(0,0,0,.12);
}
.tpanel > header {
  display: flex; align-items: center; gap: 9px; padding: 12px 14px;
  background: var(--panel-head); color: var(--panel-text); font-weight: 600; font-size: 15px;
}
.tpanel > header .grow { flex: 1; }
.tpanel > header .iconbtn { color: #fff; }
.tpanel > header .iconbtn:hover { background: rgba(255,255,255,.18); }

.tpanel .ptabs { display: flex; border-bottom: 1px solid var(--border-2); background: var(--surface); }
.tpanel .ptabs button {
  flex: 1; border: 0; background: transparent; padding: 12px 8px; cursor: pointer;
  font-weight: 600; color: var(--text-weak); border-bottom: 3px solid transparent;
}
.tpanel .ptabs button.active { color: var(--text); border-bottom-color: var(--panel-head); }
.tpanel .ptabs button:hover { background: var(--surface-2); }
.tpanel .pbody { flex: 1; overflow-y: auto; }
.tpanel .pbody.pad { padding: 14px; }

/* availability toggle, in the Phone header */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.switch input { display: none; }
.switch .track {
  width: 42px; height: 23px; border-radius: 12px; background: rgba(255,255,255,.3);
  position: relative; transition: background .14s; cursor: pointer;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px;
  border-radius: 50%; background: #fff; transition: transform .14s;
}
.switch input:checked + .track { background: #2ecc71; }
.switch input:checked + .track::after { transform: translateX(19px); }

/* dialer */
.d-display {
  width: 100%; height: 46px; padding: 0 14px; text-align: center; font-size: 19px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  font-variant-numeric: tabular-nums; margin-bottom: 4px;
}
.d-display:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.d-sub { text-align: center; min-height: 17px; color: var(--text-weak); font-size: 12px; margin-bottom: 12px; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; justify-items: center; }
.keypad button {
  width: 66px; height: 66px; border-radius: 50%; border: 1px solid var(--border-2);
  background: var(--surface); cursor: pointer; display: grid; place-items: center;
  line-height: 1.05; transition: background .08s;
}
.keypad button:hover { background: var(--brand-tint); border-color: var(--brand-tint-2); }
.keypad button:active { background: var(--brand-tint-2); }
.keypad .kd { font-size: 22px; font-weight: 500; }
.keypad .kl { font-size: 9px; letter-spacing: .12em; color: var(--text-weak); }

.d-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.btn-call {
  flex: 1; height: 46px; border: 0; border-radius: 6px; background: var(--success); color: #fff;
  font-weight: 700; font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-call:hover { background: #24663a; }
.btn-call:disabled { background: #bcc7c0; cursor: not-allowed; }
.btn-back {
  width: 46px; height: 46px; border: 1px solid var(--border-2); border-radius: 6px;
  background: var(--surface); cursor: pointer; color: var(--text-weak); font-size: 16px;
}
.btn-back:hover { background: var(--surface-2); color: var(--text); }

/* in-call */
.d-call { padding: 18px 14px; text-align: center; }
.d-call .who { font-size: 18px; font-weight: 600; }
.d-call .num { color: var(--text-weak); font-variant-numeric: tabular-nums; }
.d-call .timer { font-size: 32px; font-weight: 300; margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
.d-call .state { color: var(--text-weak); font-size: 12px; }
.d-call-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.btn-round {
  width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; display: grid; place-items: center;
  color: var(--text-weak); font-size: 10px; gap: 1px;
}
.btn-round:hover { background: var(--surface-2); }
.btn-round.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-round svg { width: 19px; height: 19px; }
.btn-round.end { background: var(--error); border-color: var(--error); color: #fff; }
.btn-round.end:hover { background: #94040f; }
.btn-round.accept { background: var(--success); border-color: var(--success); color: #fff; }

/* call logs / conversation rows */
.logrow, .convrow {
  display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border-2);
  cursor: pointer; align-items: flex-start;
}
.logrow:hover, .convrow:hover { background: var(--brand-tint); }
.logrow .grow, .convrow .grow { flex: 1; min-width: 0; }
.logrow .nm, .convrow .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logrow .sub, .convrow .sub { color: var(--text-weak); font-size: 12px; }
.convrow.unread .nm::after {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); margin-left: 6px; vertical-align: middle;
}
.dirdot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.dirdot.in  { background: var(--success-bg); color: var(--success); }
.dirdot.out { background: var(--brand-tint); color: var(--brand-dark); }
.dirdot.missed { background: var(--error-bg); color: var(--error); }
.dirdot svg { width: 14px; height: 14px; }

/* ------------------------------------------------- threads and the composer */
.thread { flex: 1; overflow-y: auto; padding: 14px; background: var(--surface-2); }
/* justify-content: flex-end on a scrolling flex column makes the top of the
   content unreachable — you cannot scroll back to older messages. */
.thread > :first-child { margin-top: auto; }
.thread { display: flex; flex-direction: column; }

.datepill {
  align-self: center; margin: 10px 0 12px; padding: 3px 12px; border-radius: 12px;
  background: var(--border-2); color: var(--text-weak); font-size: 11px; font-weight: 600;
}
.bubble { max-width: 78%; padding: 9px 12px; border-radius: 10px; margin-bottom: 4px; }
.bubble .btext { white-space: pre-wrap; word-break: break-word; }
.bubble .bmeta { font-size: 10.5px; margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.bubble.in {
  align-self: flex-start; background: var(--surface); border: 1px solid var(--border-2);
  border-bottom-left-radius: 3px;
}
.bubble.in .bmeta { color: var(--text-weak); }
.bubble.out {
  align-self: flex-end; background: var(--bubble-out); color: #fff;
  border-bottom-right-radius: 3px;
}
.bubble.out .bmeta { color: rgba(255,255,255,.85); justify-content: flex-end; }
.bubble.pending {
  align-self: flex-end; background: var(--surface); border: 1px dashed var(--border);
  color: var(--text-weak); border-bottom-right-radius: 3px;
}
.bubble.failed { align-self: flex-end; background: var(--error-bg); border: 1px solid #f5b8b0; }
.bubble.failed .bmeta { color: var(--error); }
.bubble img { max-width: 100%; border-radius: 7px; margin-bottom: 6px; display: block; }
.ticks { letter-spacing: -2px; }

.composer { border-top: 1px solid var(--border-2); padding: 11px 12px; background: var(--surface); }
.composer .crow { display: flex; gap: 6px; align-items: center; margin-bottom: 7px; }
.composer .crow .select { height: 28px; padding: 2px 6px; font-size: 12px; }
.composer textarea {
  width: 100%; min-height: 62px; max-height: 160px; resize: vertical; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 6px;
}
.composer textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.composer .count { font-size: 11px; color: var(--text-weak); margin-top: 5px;
  font-variant-numeric: tabular-nums; }
.composer .count.warn { color: var(--warning); }
.composer .tools { display: flex; gap: 4px; align-items: center; margin-top: 7px; }
.composer .tools .grow { flex: 1; }
.composer .toolbtn {
  width: 32px; height: 32px; border: 1px solid var(--border-2); border-radius: 6px;
  background: var(--surface); cursor: pointer; color: var(--text-weak);
  display: grid; place-items: center; font-size: 15px;
}
.composer .toolbtn:hover { background: var(--surface-2); color: var(--text); }
.composer .toolbtn svg { width: 15px; height: 15px; }
.btn-send {
  width: 40px; height: 34px; border: 0; border-radius: 6px; background: var(--brand);
  color: #fff; cursor: pointer; display: grid; place-items: center;
}
.btn-send:hover { background: var(--brand-dark); }
.btn-send:disabled { background: var(--border); cursor: not-allowed; }
#sms-att-box { margin-top: 7px; }   /* its own container: opening the emoji picker must not wipe it */
.emojigrid {
  position: absolute; bottom: 100%; left: 0; width: 250px; max-height: 190px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 6px; display: grid;
  grid-template-columns: repeat(8, 1fr); gap: 2px; z-index: 5;
}
.emojigrid button { border: 0; background: transparent; cursor: pointer; font-size: 17px;
  padding: 3px; border-radius: 3px; }
.emojigrid button:hover { background: var(--brand-tint); }

/* the SMS and Activity cards on a record */
.card.gadget > header { background: var(--panel-head); color: #fff; border-bottom: 0; }
.card.gadget > header .iconbtn { color: #fff; }
.card.gadget > header .iconbtn:hover { background: rgba(255,255,255,.18); }
/* Tall enough that a conversation actually reads as one. */
.card.gadget { border-radius: 10px; overflow: hidden; }
.card.gadget > header:first-child { border-radius: 10px 10px 0 0; }
.card.gadget .thread { height: 460px; max-height: 60vh; border-radius: 0; }
.gadget-tabs { display: flex; border-bottom: 1px solid var(--border-2); }
.gadget-tabs button {
  flex: 1; border: 0; background: transparent; padding: 10px 6px; cursor: pointer;
  font-weight: 600; color: var(--text-weak); border-bottom: 3px solid transparent; font-size: 12px;
}
.gadget-tabs button.active { color: var(--text); border-bottom-color: var(--panel-head); }
.actrow { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border-2); }
.actrow .grow { flex: 1; min-width: 0; }
.actrow .when { font-weight: 600; }
.actrow .sub { color: var(--text-weak); font-size: 12px; }
.actrow audio { width: 100%; max-width: 260px; margin-top: 6px; height: 32px; }

@media (max-width: 900px) { .tpanel.right { width: 100%; } }
@media (max-width: 640px) {
  .softbar { gap: 6px; padding: 0 7px; }
  .softbar .sb-status span:not(.dot) { display: none; }
  .softbar .testchip { display: none; }
  .dialer { left: 8px; right: 8px; width: auto; }
}

/* .switch was built for the dark telephony bar; on a white card the off-state
   track is invisible against the surface. */
.card .switch .track { background: #cbd5e1; }
