:root {
  --ovr-blue: #41b6e6;
  --ovr-blue-dark: #1f97c9;
  --ovr-blue-soft: #e6f5fc;
  --graphite: #1d2023;
  --graphite-2: #2a2e33;
  --graphite-3: #3a3f45;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1d2023;
  --muted: #6b7280;
  --line: #e3e7eb;
  --red: #e5484d;
  --red-soft: #fdecec;
  --amber: #d98a00;
  --amber-soft: #fff4dc;
  --green: #1f9d55;
  --green-soft: #e3f6eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--ovr-blue-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.error { color: var(--red); min-height: 1em; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--graphite); padding: 16px; }
.login-card { background: var(--graphite-2); color: #fff; padding: 32px; border-radius: 16px; width: 100%; max-width: 360px; display: grid; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-card h1 { font-size: 18px; font-weight: 600; color: var(--ovr-blue); margin-top: -6px; }
.login-logo { height: 42px; justify-self: start; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: #c9ced4; }
.login-card input { background: var(--graphite); border: 1px solid var(--graphite-3); color: #fff; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--graphite); color: #cfd4da; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; text-decoration: none !important; }
.brand img { height: 26px; }
.brand span { font-weight: 600; font-size: 13px; color: var(--ovr-blue); letter-spacing: .04em; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #cfd4da; text-decoration: none; font-weight: 500; }
.sidebar nav a:hover { background: var(--graphite-2); color: #fff; }
.sidebar nav a.active { background: var(--ovr-blue); color: var(--graphite); }
.sidebar .ico { width: 18px; text-align: center; font-size: 13px; }
.badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 600; }
.sidebar nav a.active .badge { background: var(--graphite); }
.me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--graphite-3); display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #fff; }
.me .link { color: #9aa3ad; }
main { padding: 24px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 14px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 14px 16px; }
.kpi { padding: 16px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.alert .value { color: var(--red); }
a.kpi { color: inherit; text-decoration: none !important; display: block; }
a.kpi:hover { border-color: var(--ovr-blue); }

/* ---------- controls ---------- */
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--ovr-blue); box-shadow: 0 0 0 3px rgba(65, 182, 230, .2); }
textarea { resize: vertical; min-height: 80px; width: 100%; }
label.field { display: grid; gap: 5px; font-size: 12px; font-weight: 500; color: var(--muted); }
.btn { font: inherit; font-weight: 500; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px; padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none !important; }
.btn:hover { border-color: #c5ccd3; background: #fafbfc; }
.btn.primary { background: var(--ovr-blue); border-color: var(--ovr-blue); color: var(--graphite); font-weight: 600; }
.btn.primary:hover { background: var(--ovr-blue-dark); border-color: var(--ovr-blue-dark); color: #fff; }
.btn.dark { background: var(--graphite); border-color: var(--graphite); color: #fff; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--ovr-blue-dark); cursor: pointer; font: inherit; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--red); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { font: inherit; border: 0; background: none; padding: 7px 12px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--graphite); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #eef1f4; color: #39414a; border: 1px solid transparent; cursor: default; white-space: nowrap; }
.chip.tag { background: var(--ovr-blue-soft); color: #0f6f99; }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; padding: 0 0 0 2px; font-size: 13px; line-height: 1; }
.chip.pick { cursor: pointer; background: #fff; border-color: var(--line); color: var(--text); font-size: 13px; padding: 5px 11px; }
.chip.pick:hover { border-color: var(--ovr-blue); }
.chip.pick.on { background: var(--graphite); border-color: var(--graphite); color: #fff; }

.status { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.st-New { background: #eef1f4; color: #4b5563; }
.st-Attempted { background: var(--amber-soft); color: #9a6200; }
.st-Contacted { background: var(--ovr-blue-soft); color: #0f6f99; }
.st-Interested { background: #e9e5ff; color: #5b3fd1; }
.st-Quote.Sent, .st-QuoteSent { background: #fff0e0; color: #b25b00; }
.st-Customer { background: var(--green-soft); color: var(--green); }
.st-Not.Interested, .st-NotInterested { background: #f1f1f1; color: #777; }
.st-Do.Not.Contact, .st-DoNotContact { background: var(--red-soft); color: var(--red); }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters .search { flex: 1 1 260px; max-width: 380px; }
.filters select { padding: 7px 8px; }
.ms { position: relative; }
.ms > .btn { font-weight: 500; }
.ms > .btn.has { border-color: var(--ovr-blue); background: var(--ovr-blue-soft); color: #0f6f99; }
.ms-pop { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); width: 260px; max-height: 340px; display: flex; flex-direction: column; }
.ms-pop input[type=search] { margin: 8px; }
.ms-list { overflow: auto; padding: 0 4px 6px; }
.ms-list label { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.ms-list label:hover { background: var(--bg); }
.ms-list label .n { margin-left: auto; color: var(--muted); font-size: 11px; }
.ms-foot { border-top: 1px solid var(--line); padding: 6px 10px; display: flex; justify-content: space-between; }
.more-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fafbfc; white-space: nowrap; position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #f7fbfe; }
tbody tr.sel { background: var(--ovr-blue-soft); }
td .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
td.chk, th.chk { width: 34px; padding-right: 0; }
.due-over { color: var(--red); font-weight: 600; }
.due-today { color: var(--amber); font-weight: 600; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
.bulkbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--graphite); color: #fff; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.bulkbar .btn { background: var(--graphite-2); border-color: var(--graphite-3); color: #fff; }
.bulkbar .btn:hover { background: var(--graphite-3); }
.bulkbar .link { color: var(--ovr-blue); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* ---------- school detail ---------- */
.crumb { font-size: 13px; margin-bottom: 8px; display: inline-block; }
.school-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.school-head .title { flex: 1; min-width: 260px; }
.school-head .title .sub { color: var(--muted); margin-top: 4px; }
.school-head .ctrls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tags-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.tags-edit input { padding: 3px 9px; border-radius: 999px; font-size: 12px; width: 140px; }
.info-list { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; word-break: break-word; }
.contact { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.contact:last-child { border-bottom: 0; }
.contact.hl { background: var(--ovr-blue-soft); }
.contact .role { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.contact .name { font-weight: 600; margin-top: 2px; }
.contact .name.ph { color: var(--muted); font-weight: 400; font-style: italic; }
.contact .lines { display: grid; gap: 2px; margin-top: 4px; font-size: 13px; }
.contact .lines .bounced { color: var(--red); text-decoration: line-through; }
.contact .acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.contact .meta { font-size: 12px; color: var(--muted); margin-left: auto; }
.copy { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 12px; padding: 0 4px; }
.copy:hover { color: var(--ovr-blue-dark); }

.composer .types { display: flex; gap: 4px; padding: 10px 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.composer .types button { font: inherit; font-weight: 500; border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.composer .types button.on { color: var(--text); border-bottom-color: var(--ovr-blue); }
.composer .body { padding: 14px 16px; display: grid; gap: 12px; }
.composer .row { display: flex; gap: 10px; flex-wrap: wrap; }
.composer .row > * { flex: 1 1 180px; }
.composer .foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
.fu-row { display: grid; gap: 8px; }

.timeline { position: relative; padding: 4px 16px 16px; }
.tl-day { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 16px 0 8px 40px; }
.tl-item { display: grid; grid-template-columns: 30px 1fr; gap: 10px; position: relative; padding-bottom: 14px; }
.tl-item::before { content: ''; position: absolute; left: 14px; top: 30px; bottom: 0; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: #eef1f4; position: relative; z-index: 1; }
.tl-ico.Call { background: var(--green-soft); }
.tl-ico.Email { background: var(--ovr-blue-soft); }
.tl-ico.Text { background: #e9e5ff; }
.tl-ico.Meeting { background: #fff0e0; }
.tl-ico.Note { background: var(--amber-soft); }
.tl-ico.System, .tl-ico.Followup { width: 30px; height: 22px; background: transparent; font-size: 11px; }
.tl-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.tl-card .top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-card .top .who { color: var(--muted); font-size: 12px; margin-left: auto; }
.tl-card .bodytext { white-space: pre-wrap; margin-top: 6px; }
.tl-card .tools { display: none; gap: 10px; margin-top: 6px; font-size: 12px; }
.tl-card:hover .tools { display: flex; }
.tl-sys { font-size: 13px; color: var(--muted); padding-top: 3px; }
.tl-sys .who { font-size: 12px; }
.outcome { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: #eef1f4; }

.fu-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.fu-item:last-child { border-bottom: 0; }
.fu-item input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--ovr-blue); }
.fu-item .grow { flex: 1; min-width: 0; }
.fu-item .snooze { display: flex; gap: 4px; flex-wrap: wrap; }

/* ---------- bars ---------- */
.bar-row { display: grid; grid-template-columns: 120px 1fr 60px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.bar { height: 10px; background: #eef1f4; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ovr-blue); border-radius: 999px; }
.feed-item { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .when { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---------- import ---------- */
.drop { display: block; border: 2px dashed #c9d2da; border-radius: 14px; padding: 40px 20px; text-align: center; background: #fff; cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--ovr-blue); background: var(--ovr-blue-soft); }
.drop .big { font-size: 34px; }
.diff-list { max-height: 320px; overflow: auto; font-size: 13px; }
.diff-list .chg { color: var(--muted); font-size: 12px; }
.warn { background: var(--amber-soft); color: #7a4d00; border-radius: 8px; padding: 10px 12px; font-size: 13px; }

/* ---------- modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(29, 32, 35, .55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 30px 70px rgba(0,0,0,.3); }
.modal.wide { max-width: 760px; }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h2 { flex: 1; }
.modal-body { padding: 16px 18px; overflow: auto; display: grid; gap: 12px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body > * { min-width: 0; }
.batch { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.batch .grow { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch.copied { border-color: var(--green); background: var(--green-soft); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--graphite); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 500; opacity: 0; pointer-events: none; transition: .2s; z-index: 200; }
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 1100px) {
  .detail { grid-template-columns: minmax(0, 1fr); }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px; }
  .brand { padding: 0 8px 0 0; }
  .brand span { display: none; }
  .sidebar nav { display: flex; overflow-x: auto; flex: 1 1 100%; order: 3; }
  .sidebar nav a { white-space: nowrap; padding: 7px 10px; }
  .me { margin: 0 0 0 auto; border: 0; padding: 0; gap: 10px; }
  main { padding: 16px 16px 60px; }
  .cols-2, .cols-4 { grid-template-columns: minmax(0, 1fr); }
  .page-head > * { max-width: 100%; }
  .filters .search { max-width: none; }
}
