/* Lead Portal — agent web app.
   Dark theme, red accent — matches the Swartz Communication tooling palette
   (#c0392b), same tokens as the UIQ portal so the two apps read as one house. */

:root {
  --bg: #1e1e1e;
  --bg2: #252526;
  --bg3: #2d2d2d;
  --fg: #d4d4d4;
  --fg-dim: #888888;
  --accent: #c0392b;
  --accent-hover: #a93226;
  --success: #5fb87a;   /* true green — teal (#4ec9b0) read as blue */
  --warn: #dcdcaa;
  --error: #f44747;
  --border: #3c3c3c;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ---- shared login/card (reused from UIQ portal look) ---- */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 32px 32px 22px; width: 100%; max-width: 430px;
}
.card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.card p.subtitle { margin: 0 0 24px; color: var(--fg-dim); font-size: 13px; }

label { display: block; font-size: 13px; margin: 16px 0 6px; color: var(--fg-dim); }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; color: var(--fg); padding: 10px 12px; font-size: 14px;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

select {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; color: var(--fg); padding: 10px 36px 10px 12px; font-size: 14px;
  font-family: inherit; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888888' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select option { background: var(--bg3); color: var(--fg); }

button {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 11px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: default; }
button.secondary { background: var(--bg3); color: var(--fg); border: 1px solid var(--border); }
button.secondary:hover { background: var(--border); }
button.ghost { background: none; color: var(--fg-dim); border: 1px solid var(--border); }
button.ghost:hover { background: var(--bg3); color: var(--fg); }
button.full { width: 100%; }

.message { margin-top: 14px; font-size: 13px; min-height: 18px; }
.message.error { color: var(--error); }
.message.success { color: var(--success); }
.message.info { color: var(--fg-dim); }
.hint { font-size: 12px; color: var(--fg-dim); margin-top: 6px; }

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 52px; background: var(--bg2);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.topbar-brand { font-size: 15px; font-weight: 700; }
.topbar-brand .accent { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { font-size: 13px; color: var(--fg-dim); }
.icon-btn {
  width: auto; padding: 6px 12px; background: none; border: 1px solid var(--border);
  color: var(--fg-dim); font-size: 13px; font-weight: 500; border-radius: 6px;
}
.icon-btn:hover { background: var(--bg3); color: var(--fg); }

/* ---- tab bar ---- */
.tab-bar { display: flex; gap: 2px; padding: 12px 24px 0; max-width: 1080px; width: 100%; margin: 0 auto; background: var(--bg); flex-shrink: 0; }
.tab-btn {
  padding: 9px 20px; background: none; border: 1px solid var(--border); border-bottom: none;
  color: var(--fg-dim); font-size: 13px; font-weight: 500;
  border-radius: 8px 8px 0 0; position: relative; bottom: -1px;
}
.tab-btn:hover { color: var(--fg); background: var(--bg3); }
.tab-btn.active { background: var(--bg2); color: var(--fg); font-weight: 600; border-bottom: 1px solid var(--bg2); }
.tab-btn.has-alert { color: var(--error) !important; }

/* admin "view as" switcher — right side of the tab bar */
.agent-switch { margin-left: auto; position: relative; align-self: center; }
.as-btn { display: flex; align-items: center; gap: 8px; width: auto; padding: 7px 12px;
  background: var(--bg3); color: var(--fg); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.as-btn:hover { background: var(--border); }
.agent-switch.viewing .as-btn { border-color: var(--accent); color: #e0736a; }
.as-btn .caret { display: flex; color: var(--fg-dim); }
.as-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 60; min-width: 180px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.as-item { padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--fg); }
.as-item:hover { background: var(--bg3); }
.as-item.active { color: #e0736a; font-weight: 600; }
.as-item.as-admin { color: var(--fg); font-weight: 600; border-bottom: 1px solid var(--border); border-radius: 0; margin-bottom: 4px; }

/* ---- panels / content ---- */
.page-content { flex: 1; overflow-y: auto; }
.panel { display: none; height: 100%; }
.panel.active { display: block; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px 24px; height: 100%; }
/* every tab's card is the same size (fills the viewport area); content scrolls inside */
.surface {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 0 8px 8px 8px;
  padding: 20px; height: 90%; overflow-y: auto;
}

.row { display: flex; gap: 12px; align-items: center; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
h2.section { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.sub { color: var(--fg-dim); font-size: 13px; margin: 0 0 18px; }

/* ---- toolbar (search + filters) ---- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type="text"] { max-width: 260px; }
.chip {
  padding: 6px 12px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 999px; color: var(--fg-dim); font-size: 12px; font-weight: 500; cursor: pointer;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- phone dialer + scrollable lists ---- */
.scroll-list { max-height: 260px; overflow-y: auto; }

/* Phone tab: dialpad left, recent calls fill the right; ONLY the call list scrolls */
#panel-phone .surface { display: flex; flex-direction: column; overflow: hidden; }
#panel-phone .surface > *:not(.phone-grid) { flex-shrink: 0; }
.phone-grid { flex: 1 1 0; min-height: 0; display: flex; gap: 16px; align-items: flex-start; }
@media (max-width: 760px) { .phone-grid { flex-direction: column; } }
.dialer {
  width: 320px; flex-shrink: 0;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 34px 20px; text-align: center;   /* taller box, symmetric so content stays centered */
}
/* recent-calls card: grows to fit the calls; scrolls only when they'd exceed the window */
.phone-recent {
  flex: 1 1 auto; align-self: flex-start;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 14px 8px;
}
@media (max-width: 760px) { .phone-recent { width: 100%; } }
.phone-recent .offices-head { margin-top: 0; }
/* Phone Contacts view — full window */
#contacts-panel { flex: 1 1 0; min-height: 0; flex-direction: column; }
.contacts-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; flex-shrink: 0; }
.contacts-tools #pc-search { flex: 1 1 220px; min-width: 180px; }
.contacts-tools select { flex: 0 0 auto; width: 150px; }
.pc-list { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; padding-right: 6px; }
.pc-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.pc-item:hover { border-color: var(--accent); }
.pc-main { min-width: 0; }
.pc-name { font-size: 14px; font-weight: 600; }
.pc-sub { font-size: 12px; color: var(--fg-dim); margin-top: 2px; }
.pc-num { font-size: 13px; color: var(--fg); white-space: nowrap; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.pc-badge { font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: rgba(95,184,122,0.16); color: var(--success); vertical-align: 1px; }
#panel-phone #call-log {
  max-height: calc(100vh - 320px);                      /* cap = window minus chrome */
  overflow-y: auto;                                     /* scroll only when it overflows */
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
#panel-phone #call-log::-webkit-scrollbar { width: 8px; }
#panel-phone #call-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
#panel-phone #call-log::-webkit-scrollbar-track { background: transparent; }
/* recent-call rows: neutral border normally, red for missed; all clickable */
#call-log .log-entry { border-left-color: var(--border); cursor: pointer; display: flex; align-items: center; gap: 8px; }
#call-log .log-entry:hover { background: var(--bg2); }
#call-log .log-entry.missed { border-left-color: var(--error); }
.call-main { flex: 1; min-width: 0; }
.missed-tag { color: var(--error); font-weight: 600; }
.vm-badge {
  flex-shrink: 0; width: auto; padding: 4px 10px; border-radius: 999px;
  background: rgba(244,71,71,0.14); color: var(--error); border: 1px solid rgba(244,71,71,0.4);
  font-size: 11px; font-weight: 600; cursor: pointer;
}
.vm-badge:hover { background: rgba(244,71,71,0.24); }
/* voicemail player */
.vm-player { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.vm-play { flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.vm-play:hover { background: var(--accent-hover); }
.vm-bar { flex: 1; height: 5px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.vm-fill { width: 22%; height: 100%; background: var(--accent); }
.vm-time { font-size: 12px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }

/* Sold tab: header fixed, ONLY the tables scroll (same rules as Recent Calls) */
#panel-sold .surface { display: flex; flex-direction: column; overflow: hidden; }
#panel-sold .surface > *:not(#sold-body) { flex-shrink: 0; }
/* align the Table/Transaction/Total slider's right edge with the tables (inset by the scrollbar gap) */
#panel-sold .surface > .row.spread { padding-right: 18px; }
#panel-sold #sold-body {
  flex: 1 1 0; min-height: 120px; padding-right: 10px;   /* gap between tables and scrollbar */
  overflow-y: scroll;                                   /* permanent scrollbar */
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
#panel-sold #sold-body::-webkit-scrollbar { width: 8px; }
#panel-sold #sold-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
#panel-sold #sold-body::-webkit-scrollbar-track { background: transparent; }

/* ---- Leads sub-nav ---- */
.subnav { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.subnav-btn {
  padding: 8px 16px; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--fg-dim); font-size: 13px; font-weight: 500; border-radius: 0;
}
.subnav-btn:hover { color: var(--fg); background: none; }
.subnav-btn.active { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.sub-panel { display: none; }
.sub-panel.active { display: block; }

/* ---- email client ---- */
/* only the preview list + reading pane scroll; folders + search stay fixed */
#panel-email .surface { display: flex; flex-direction: column; overflow: hidden; }
#panel-email .surface > *:not(.email-grid) { flex-shrink: 0; }
.email-grid {
  flex: 1 1 0; min-height: 0;
  display: grid; grid-template-columns: 150px 320px 1fr; grid-template-rows: auto 1fr;
  grid-template-areas: "folders search search" "folders list view";
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
@media (max-width: 860px) { .email-grid { grid-template-columns: 130px 1fr; grid-template-areas: "folders search" "folders list"; } .mail-view { display: none; } }
.mail-folders { grid-area: folders; background: var(--bg3); border-right: 1px solid var(--border); padding: 8px; overflow-y: auto; }
.folder { padding: 8px 12px; border-radius: 6px; font-size: 13px; color: var(--fg-dim); cursor: pointer; display: flex; justify-content: space-between; }
.folder:hover { background: var(--bg2); color: var(--fg); }
.folder.active { background: var(--accent); color: #fff; }
.folder.flag-alert { color: var(--error); }
.folder.flag-alert.active { color: #fff; }
.folder .cnt { font-size: 11px; opacity: .8; }
/* integrated search bar across the top of list + view */
.mail-search { grid-area: search; display: flex; gap: 8px; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); }
.mail-field { flex: 1 1 auto; }
.refresh-btn { flex: 0 0 auto; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  padding: 0; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--muted, #a9a9ad); cursor: pointer; }
.refresh-btn:hover { color: var(--fg); border-color: #555; }
.refresh-btn.spin svg { animation: rf-spin .6s linear; transform-origin: 50% 50%; }
@keyframes rf-spin { to { transform: rotate(360deg); } }

/* reading pane: reply / thread */
.mail-view-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.mail-head { min-width: 0; }
.link-btn { background: transparent; color: #e0736a; border: 1px solid #c0392b; border-radius: 8px; cursor: pointer; }
.link-btn:hover { background: #c0392b; color: #fff; }
.mail-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: auto; padding-top: 18px; }

/* agent orientation cards (onboarding step 0) */
.ob-card { max-height: 52vh; overflow-y: auto; font-size: 14px; line-height: 1.55; color: var(--fg); }
.ob-card p { margin: 0 0 12px; }
.ob-card ul { margin: 0 0 12px; padding-left: 20px; }
.ob-card li { margin: 6px 0; }
.ob-card b { color: #fff; }
.ob-status { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: 13px; }
.ob-status th, .ob-status td { text-align: left; padding: 8px 10px; border: 1px solid var(--border); vertical-align: top; }
.ob-status th { background: var(--bg3); color: var(--fg-dim); font-weight: 600; }
.ob-ack { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0 4px; font-size: 13px; color: var(--fg); line-height: 1.5; }
.mail-quote { margin-top: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.quote-label { font-size: 12px; color: #8a8a8e; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.quote-body { padding: 12px; white-space: pre-wrap; color: #b9b9bd; max-height: 200px; overflow: auto; }
.quote-foot { padding: 10px 12px; border-top: 1px solid var(--border); }
.thread-actions { margin-top: 16px; }
.thread-scroll { max-height: 62vh; overflow: auto; display: flex; flex-direction: column; gap: 12px; margin: 18px 0 4px; padding-right: 4px; }
.th-msg { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.th-msg.out { background: var(--bg3); }
.th-head { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: #8a8a8e; margin-bottom: 6px; }
.th-date { flex: 0 0 auto; white-space: nowrap; }
.th-who { min-width: 0; }
.th-body { white-space: pre-wrap; font-size: 14px; line-height: 1.45; }
.mail-field input, .mail-field select { width: 100%; }
/* custom mode dropdown (aligns under the button, unlike native select) */
.mode-dd { position: relative; flex-shrink: 0; }
.mode-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 150px; font-size: 14px; font-weight: 400;
  background: var(--bg3); border: 1px solid var(--border); color: var(--fg);
  padding: 10px 12px; border-radius: 6px;
}
.mode-btn:hover { background: var(--bg3); }
.mode-btn .caret { display: inline-flex; align-items: center; }
.mode-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.mode-item { padding: 9px 12px; font-size: 13px; color: var(--fg); cursor: pointer; }
.mode-item:hover { background: var(--bg3); }
/* searchable category combobox */
.combo { position: relative; }
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  max-height: 240px; overflow-y: auto; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.combo-item { padding: 8px 11px; font-size: 13px; color: var(--fg); cursor: pointer; }
.combo-item:hover { background: var(--bg3); }
/* date range + calendar-icon fields */
.date-range { display: flex; align-items: center; gap: 30px; padding-left: 30px; }  /* space before To (gap) = space before From (padding) */
.dr-group { display: inline-flex; align-items: center; gap: 10px; }
.dr-label { font-size: 14px; color: var(--fg); flex-shrink: 0; }
.dp { position: relative; display: inline-block; }
.dp .date-inp { width: 190px; }   /* beats the global input{width:100%} so it truly matches the calendar */
/* custom calendar popup — app grey, same width as the box */
.cal-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 190px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--fg); }
.cal-head button { width: auto; background: none; border: none; color: var(--fg-dim); font-size: 18px; line-height: 1; padding: 0 8px; cursor: pointer; }
.cal-head button:hover { color: var(--fg); background: none; }
.cal-wk { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 11px; color: var(--fg-dim); text-align: center; margin-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day { text-align: center; font-size: 12px; padding: 6px 0; border-radius: 4px; cursor: pointer; color: var(--fg); }
.cal-day.empty { visibility: hidden; }
.cal-day:not(.empty):hover { background: var(--bg3); }
.cal-day.sel { background: var(--accent); color: #fff; }
.mail-list { grid-area: list; border-right: 1px solid var(--border); overflow-y: auto; min-height: 0; }
.mail-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.mail-item:hover { background: var(--bg3); }
.mail-item.active { background: var(--bg3); border-left: 3px solid var(--accent); }
.mail-item.unread .mail-from { font-weight: 700; }
.mail-row1 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.mail-from { font-size: 13px; color: var(--fg); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-date { font-size: 11px; color: var(--fg-dim); white-space: nowrap; flex-shrink: 0; }
.mail-row2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; min-height: 16px; }
.mail-actions { display: flex; gap: 8px; flex-shrink: 0; margin-left: auto; }
.star { background: none; border: none; color: var(--fg-dim); font-size: 15px; line-height: 1; padding: 0; width: auto; cursor: pointer; }
.star:hover { color: var(--warn); background: none; }
.star.on { color: var(--warn); }
.flag { background: none; border: none; color: var(--fg-dim); font-size: 14px; line-height: 1; padding: 0; width: auto; cursor: pointer; }
.flag:hover { color: var(--error); background: none; }
.flag.on { color: var(--error); }
.mail-subj { font-size: 12px; color: var(--fg-dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-tags { display: flex; gap: 4px; flex-wrap: wrap; min-width: 0; }
.mail-view { grid-area: view; padding: 18px; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; }
.mail-view h3 { margin: 0 0 4px; font-size: 15px; }
.mail-meta { font-size: 12px; color: var(--fg-dim); margin-bottom: 14px; }
.mail-body { font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.client-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: rgba(192,57,43,0.16); color: #e6897e; }

/* ---- sold table ---- */
.sold-chain { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 16px; overflow: hidden; }
.sold-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg3); }
.sold-head .who { font-size: 14px; font-weight: 600; }
.sold-head .meta { font-size: 12px; color: var(--fg-dim); }
/* table-layout:fixed = every client's table (incl. ones with an Ended row) aligns identically */
table.sold { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
/* Table view (6 cols): Date · Type · Price/pc · Volume · You earned · Paid */
table.sold:not(.tx) th:nth-child(1) { width: 18%; }
table.sold:not(.tx) th:nth-child(2) { width: 22%; }
table.sold:not(.tx) th:nth-child(3) { width: 15%; }
table.sold:not(.tx) th:nth-child(4) { width: 15%; }
table.sold:not(.tx) th:nth-child(5) { width: 16%; }
table.sold:not(.tx) th:nth-child(6) { width: 14%; }
/* Transaction view (7 cols): Date · Client · Type · Price/pc · Volume · You earned · Paid */
table.sold.tx th:nth-child(1) { width: 13%; }
table.sold.tx th:nth-child(2) { width: 21%; }
table.sold.tx th:nth-child(3) { width: 16%; }
table.sold.tx th:nth-child(4) { width: 13%; }
table.sold.tx th:nth-child(5) { width: 13%; }
table.sold.tx th:nth-child(6) { width: 15%; }
table.sold.tx th:nth-child(7) { width: 9%; }
table.sold th, table.sold td { padding: 8px 14px; text-align: left; border-top: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; }
table.sold th { color: var(--fg-dim); font-weight: 500; font-size: 12px; }
table.sold th.num, table.sold td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.sold th.earned, table.sold td.earned { text-align: center; font-variant-numeric: tabular-nums; }
table.sold .row-ended td { color: var(--warn); font-weight: 600; text-align: center; letter-spacing: .3px; }
table.sold .pill-paid { cursor: help; }
.totals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.totals-grid .stat-num.pos { color: var(--accent); }
.totals-grid .stat-num.warn { color: var(--warn); }
.totals-grid .stat-tile { cursor: pointer; transition: border-color .1s, background .1s; }
.totals-grid .stat-tile:hover { border-color: var(--accent); background: var(--bg2); }
/* detail drill-down tables in the Total modal */
.mini-wrap { max-height: 52vh; overflow: auto; margin-top: 6px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
table.mini th, table.mini td { padding: 6px 9px; text-align: left; border-top: 1px solid var(--border); }
table.mini th { color: var(--fg-dim); font-weight: 500; position: sticky; top: 0; background: var(--bg2); }
table.mini td.num, table.mini th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill-paid { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: rgba(192,57,43,0.16); color: var(--accent); }
.pill-unpaid { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: rgba(220,220,170,0.14); color: var(--warn); }

/* ---- assigned zips (territory) ---- */
.zips-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); margin: 4px 0 8px; }
.offices-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); margin: 20px 0 10px; }
.zip-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.zip-card {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; min-width: 116px; cursor: pointer;
}
.zip-card:hover { border-color: var(--accent); }
.zip-card.sel { border-color: var(--accent); background: rgba(192,57,43,0.10); }
.zip-card .z { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.zip-card .z .pri { font-size: 10px; color: var(--success); font-weight: 700; margin-left: 6px; vertical-align: 2px; }
.zip-card .zc { font-size: 11px; color: var(--fg-dim); margin-top: 2px; }
.zip-card .zc.hold { margin-top: 4px; }
.zip-card .zc.hold.exp { color: var(--accent); font-weight: 600; }
.zip-card .zc.hold .renew-link { color: var(--accent); text-decoration: none; }
.zip-card .zc.hold .renew-link:hover { text-decoration: underline; }
.claim-more { color: var(--accent); font-size: 12px; font-weight: 700; text-transform: none; letter-spacing: 0; text-decoration: none; }
.claim-more:hover { text-decoration: underline; }

/* ---- open pool ---- */
.grab-counter { font-size: 12px; color: var(--warn); font-weight: 600; }
.claim-btn { width: auto; padding: 7px 14px; }

/* ---- suggested actions feed ---- */
.action-row { display: flex; align-items: center; gap: 11px; padding: 7px 12px; margin-bottom: 6px; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.action-row:hover { border-color: var(--accent); }
.action-ico { width: 30px; height: 30px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; background: var(--bg3); color: var(--fg-dim); }
.action-ico.renew, .action-ico.missed { background: rgba(192,57,43,0.15); color: var(--accent); }
.action-ico.email, .action-ico.followup, .action-ico.paid { background: rgba(192,57,43,0.12); color: var(--accent); }
.action-main { flex: 1; min-width: 0; }
.action-title { font-size: 14px; font-weight: 600; color: var(--fg); }
.action-meta { font-size: 12px; color: var(--fg-dim); margin-top: 2px; }
.action-tag { flex: 0 0 100px; display: flex; align-items: center; justify-content: center; }
.action-badge { flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; background: rgba(192,57,43,0.15); color: var(--accent); }
.action-badge.paid { background: rgba(192,57,43,0.15); color: var(--accent); }
.action-done { flex-shrink: 0; width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--bg3); border: 1px solid var(--border); color: var(--fg-dim); cursor: pointer; }
.action-done:hover { background: var(--success); border-color: var(--success); color: #fff; }

/* Leads card scrolls its active list, header + zips stay put (matches Phone/Sold) */
#panel-leads .surface { display: flex; flex-direction: column; overflow: hidden; }
#panel-leads .surface > *:not(.sub-panel) { flex-shrink: 0; }
#panel-leads .sub-panel.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#panel-leads .sub-panel.active > *:not(#suggested-list):not(#lead-table-wrap):not(#recent-list) { flex-shrink: 0; }
#suggested-list, #lead-table-wrap, #panel-leads #recent-list {
  flex: 1; min-height: 0; overflow-y: auto; padding-right: 10px;   /* gutter so the scrollbar clears the rows */
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
#suggested-list::-webkit-scrollbar, #lead-table-wrap::-webkit-scrollbar, #panel-leads #recent-list::-webkit-scrollbar { width: 8px; }
#suggested-list::-webkit-scrollbar-thumb, #lead-table-wrap::-webkit-scrollbar-thumb, #panel-leads #recent-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
#suggested-list::-webkit-scrollbar-track, #lead-table-wrap::-webkit-scrollbar-track, #panel-leads #recent-list::-webkit-scrollbar-track { background: transparent; }

/* ---- My Leads tools (search + filters, contacts-style) ---- */
.lead-tools { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box .search-ico { position: absolute; left: 11px; width: 15px; height: 15px; color: var(--fg-dim); pointer-events: none; }
.search-box input[type="text"] { width: 240px; padding-left: 34px; }
.sort-caret { display: inline-flex; align-items: center; margin-left: 5px; color: var(--fg-dim); transition: transform .12s ease; }
.sort-caret.up { transform: rotate(180deg); }
.ztable th.sortable:hover .sort-caret { color: var(--fg); }

/* ---- My Leads zip table ---- */
.ztable { width: 100%; border-collapse: collapse; font-size: 13px; }
.ztable th, .ztable td { padding: 10px 14px; text-align: left; border-top: 1px solid var(--border); }
.ztable thead th { position: sticky; top: 0; z-index: 2; background: var(--bg2); color: var(--fg-dim); font-weight: 500; font-size: 12px; border-top: none; }
.ztable th.num, .ztable td.num { text-align: center; font-variant-numeric: tabular-nums; }
.ztable th.sortable { cursor: pointer; user-select: none; }
.ztable th.sortable:hover { color: var(--fg); }
.ztable tbody tr { cursor: pointer; }
.ztable tbody tr:hover td { background: var(--bg3); }
.ztable .zc-zip { font-weight: 700; font-variant-numeric: tabular-nums; }
.ztable .zc-sub { display: block; font-size: 11px; font-weight: 400; color: var(--fg-dim); margin-top: 1px; }
.zstat { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.zstat.active { background: rgba(192,57,43,0.15); color: var(--accent); }
.zstat.sold { background: rgba(192,57,43,0.15); color: var(--accent); }

/* ---- lead list ---- */
.lead-list { display: flex; flex-direction: column; gap: 8px; }
.lead-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.lead-row:hover { border-color: var(--accent); }
.lead-main { flex: 1; min-width: 0; }
.lead-title { font-size: 14px; font-weight: 600; }
.lead-meta { font-size: 12px; color: var(--fg-dim); margin-top: 2px; }
.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.brand { background: var(--bg3); color: var(--fg-dim); border: 1px solid var(--border); }
.badge.geico { background: rgba(192,57,43,0.16); color: var(--accent); }
.status-dot { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.st-working { background: rgba(220,220,170,0.14); color: var(--warn); }
.st-callback { background: rgba(192,57,43,0.16); color: var(--accent); }
.st-interested { background: rgba(220,220,170,0.14); color: var(--warn); }
.st-closed { background: var(--accent); color: #fff; }
.st-dead { background: var(--bg2); color: var(--fg-dim); }
.st-new { background: var(--bg2); color: var(--fg-dim); border: 1px dashed var(--border); }
.timer { font-size: 12px; color: var(--warn); font-variant-numeric: tabular-nums; }

/* ---- territory map ---- */
.map-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 820px) { .map-grid { grid-template-columns: 1fr; } }
.us-map { width: 100%; height: auto; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; }
.us-map .state { fill: #34342f; stroke: var(--bg); stroke-width: 1; cursor: pointer; }
.us-map .state:hover { fill: #454540; }
.us-map .state.sold { fill: #5a2d27; }
.us-map .state.locked { fill: #2a2a2a; cursor: not-allowed; }
.us-map .state.sel { fill: var(--accent); }
.map-side { display: flex; flex-direction: column; gap: 14px; }
.stat-tile { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.stat-num { font-size: 26px; font-weight: 700; color: var(--fg); }
.stat-lbl { font-size: 12px; color: var(--fg-dim); margin-top: 2px; }
.zip-check { display: flex; gap: 8px; }
.zip-check input { max-width: none; }
.zip-result { margin-top: 8px; font-size: 13px; min-height: 18px; }
.zip-free { color: var(--success); font-weight: 600; }
.zip-taken { color: var(--fg-dim); font-weight: 600; }
.zip-locked { color: var(--error); font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--fg-dim); margin-top: 6px; }
.legend span::before { content: ""; display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.lg-sold::before { background: #5a2d27; } .lg-open::before { background: #34342f; } .lg-locked::before { background: #2a2a2a; }

/* ---- workspace (opens over the app) ---- */
.workspace { position: fixed; inset: 0; background: var(--bg); display: none; flex-direction: column; z-index: 40; }
.workspace.open { display: flex; }
.ws-bar { display: flex; align-items: center; gap: 14px; padding: 0 20px; height: 52px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ws-back { padding: 6px 12px; }
.ws-title { font-size: 15px; font-weight: 700; }
.ws-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 0; overflow: hidden; }
@media (max-width: 900px) { .ws-body { grid-template-columns: 1fr; overflow-y: auto; } }
.ws-col { overflow-y: auto; padding: 20px; }
.ws-col.left { border-right: 1px solid var(--border); }

.info-block { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.info-block h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); }
.kv { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--fg-dim); }

/* contact log timeline */
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-entry { background: var(--bg3); border-left: 3px solid var(--accent); border-radius: 4px; padding: 8px 12px; }
.log-when { font-size: 11px; color: var(--fg-dim); }
.log-body { font-size: 13px; margin-top: 2px; }

/* script + pricing */
.script { font-size: 13px; line-height: 1.5; }
.script .line { padding: 6px 0; border-bottom: 1px solid var(--border); }
.script-custom { font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.tt-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tt-controls .mode-btn { width: auto; min-width: 128px; padding: 6px 10px; font-size: 13px; }
.script .cue { color: var(--accent); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; display: block; margin-bottom: 2px; }
table.price { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
table.price th, table.price td { border: 1px solid var(--border); padding: 6px 8px; text-align: center; }
table.price th { background: var(--bg3); color: var(--fg-dim); }

/* comms — softphone + email */
.dialpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 240px; margin: 0 auto 12px; }
.dialpad button { background: var(--bg3); border: 1px solid var(--border); color: var(--fg); font-size: 18px; padding: 14px 0; }
.dialpad button:hover { background: var(--border); }
.phone-display { text-align: center; font-size: 20px; font-variant-numeric: tabular-nums; padding: 0 0 12px; letter-spacing: 1px; white-space: nowrap; }

.undo-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200;
  display: flex; align-items: center; gap: 14px; background: #23262b; color: #e8e8ea;
  border: 1px solid #3a3d44; border-radius: 8px; padding: 11px 16px; font-size: 14px;
  box-shadow: 0 6px 22px rgba(0,0,0,.4); }
.undo-toast button { background: none; border: none; color: #e0736a; font-weight: 600; cursor: pointer; padding: 0; font-size: 14px; }
.undo-toast button:hover { color: #c0392b; }
.call-btn { background: var(--accent); color: #fff; }
.call-btn:hover { background: var(--accent-hover); }
.comm-tabs { display: flex; gap: 2px; margin-bottom: 14px; }

.compose .send-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
/* Compose button matches the height of the .seg slider used on other tabs */
#btn-compose { padding: 10px 18px; font-size: 13px; }
.delay-note { font-size: 12px; color: var(--warn); }

/* ---- segmented toggle (Table / Transaction) ---- */
.seg { display: inline-flex; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 3px; flex-shrink: 0; }
.seg-btn { width: auto; padding: 6px 14px; background: none; border: none; border-radius: 6px; color: var(--fg-dim); font-size: 13px; font-weight: 500; cursor: pointer; }
.seg-btn:hover { color: var(--fg); background: none; }
.seg-btn.active { background: var(--accent); color: #fff; }

/* ---- modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal-back.open { display: flex; }
.modal { position: relative; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 24px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; }
/* wide, top-anchored variant (Total drill-downs) — same start height regardless of content */
.modal.wide { max-width: 760px; align-self: flex-start; margin-top: 9vh; max-height: 78vh; }
.modal-x { position: absolute; top: 12px; right: 12px; width: auto; background: none; border: none; color: var(--fg-dim); font-size: 15px; line-height: 1; padding: 4px 8px; cursor: pointer; }
.modal-x:hover { color: var(--fg); background: none; }
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal .btn-row { display: flex; gap: 10px; margin-top: 20px; }
.modal .btn-row button { flex: 1; }
.req::after { content: " *"; color: var(--accent); }
