/* RPR CRM styles: clean SaaS look, navy rail + light workspace */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --navy: #0f172a;
  --navy-2: #1e293b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.boot { padding: 60px; text-align: center; color: var(--muted); }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px 44px; width: 420px; max-width: 92vw; box-shadow: 0 24px 64px rgba(0,0,0,.35); }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-logo .mark { width: 42px; height: 42px; border-radius: 10px; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; }
.login-logo h1 { font-size: 22px; }
.login-sub { color: var(--muted); margin-bottom: 24px; }
.login-user { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border: 1px solid var(--border); background: #fff; border-radius: 10px; margin-bottom: 10px; transition: all .12s; }
.login-user:hover { border-color: var(--blue); background: #f0f6ff; }
.login-user .who { flex: 1; }
.login-user .who b { display: block; }
.login-user .who span { color: var(--muted); font-size: 12.5px; }

/* ---- App shell ---- */
.shell { display: flex; height: 100vh; overflow: hidden; }
.rail {
  width: 216px; min-width: 216px; background: var(--navy); color: #cbd5e1;
  display: flex; flex-direction: column; padding: 14px 10px;
}
.rail .brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; color: #fff; }
.rail .brand .mark { width: 32px; height: 32px; border-radius: 8px; background: var(--blue); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px; color: #fff; }
.rail .brand b { font-size: 15.5px; }
.rail .brand span { display: block; font-size: 10.5px; color: #94a3b8; font-weight: 400; }
.rail nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.rail nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px;
  color: #cbd5e1; font-weight: 500; font-size: 13.5px;
}
.rail nav a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.rail nav a.on { background: var(--blue); color: #fff; }
.rail nav a svg { width: 17px; height: 17px; flex: none; }
.rail nav a .count { margin-left: auto; background: rgba(255,255,255,.16); border-radius: 999px; font-size: 11px; padding: 1px 7px; }
.rail .me { display: flex; align-items: center; gap: 10px; padding: 10px 10px 4px; border-top: 1px solid var(--navy-2); margin-top: 10px; }
.rail .me .who { flex: 1; min-width: 0; }
.rail .me .who b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail .me .who span { font-size: 11px; color: #94a3b8; }
.rail .me button { background: none; border: none; color: #94a3b8; padding: 4px; }
.rail .me button:hover { color: #fff; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 20px; flex: none;
}
.topbar h2 { font-size: 17px; margin-right: 6px; }
.topbar .search { position: relative; flex: 1; max-width: 420px; }
.topbar .search input {
  width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); outline: none;
}
.topbar .search input:focus { border-color: var(--blue); background: #fff; }
.topbar .search svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--muted); }
.search-pop {
  position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(15,23,42,.14); max-height: 340px; overflow: auto; z-index: 60;
}
.search-pop .hit { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; }
.search-pop .hit:hover { background: #f0f6ff; }
.search-pop .hit .sub { color: var(--muted); font-size: 12px; }
.topbar .spacer { flex: 1; }

.content { flex: 1; overflow: auto; padding: 20px; }

/* ---- Buttons, badges, pills ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border);
  background: #fff; border-radius: 8px; padding: 7px 13px; font-weight: 600; font-size: 13px;
  color: var(--text); white-space: nowrap;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; }
.icon-btn { border: none; background: none; padding: 5px; border-radius: 6px; color: var(--muted); display: inline-flex; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap;
}
.tag { display: inline-block; background: #eef2f7; color: #475569; border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 600; margin: 1px 2px 1px 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; color: #fff; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px; flex: none;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 52px; height: 52px; font-size: 19px; }

/* ---- Cards & layout ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.card .card-head h3 { font-size: 14px; }
.card .card-head .spacer { flex: 1; }
.card .card-body { padding: 16px; }
.grid { display: grid; gap: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 34px 16px; }

/* ---- Stat cards ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; }
.stat:hover { border-color: var(--blue); }
.stat .n { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.stat .l { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-top: 2px; }
.stat.alert .n { color: var(--red); }

/* ---- Tables ---- */
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); background: #f8fafc;
  position: sticky; top: 0; z-index: 5;
}
table.list td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr.row { cursor: pointer; }
table.list tr.row:hover { background: #f0f6ff; }
table.list td .sub { color: var(--muted); font-size: 12px; margin-top: 1px; }

/* ---- People page ---- */
.people-layout { display: flex; gap: 16px; align-items: flex-start; }
.filter-rail { width: 220px; min-width: 220px; }
.filter-rail .sect { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; padding: 12px 12px 6px; }
.filter-rail .fitem {
  display: flex; align-items: center; gap: 9px; padding: 7px 12px; border-radius: 8px;
  cursor: pointer; font-weight: 500; color: var(--text); font-size: 13.5px;
}
.filter-rail .fitem:hover { background: #eef2f7; }
.filter-rail .fitem.on { background: #e0eaff; color: var(--blue-dark); font-weight: 700; }
.filter-rail .fitem .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.filter-rail .fitem .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.people-table-wrap { flex: 1; min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=text], .toolbar select {
  padding: 7px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff; outline: none;
}
.toolbar input[type=text]:focus { border-color: var(--blue); }

/* ---- Person page ---- */
.person-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.person-head .title h2 { font-size: 21px; }
.person-head .title .sub { color: var(--muted); }
.person-head .spacer { flex: 1; }
.person-layout { display: grid; grid-template-columns: 330px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .person-layout { grid-template-columns: 1fr; } }
.kv { display: flex; padding: 6px 0; gap: 10px; }
.kv .k { width: 92px; min-width: 92px; color: var(--muted); font-size: 12.5px; padding-top: 1px; }
.kv .v { flex: 1; word-break: break-word; }
.editable { border-bottom: 1px dashed transparent; cursor: pointer; }
.editable:hover { border-bottom-color: var(--blue); }

/* Timeline */
.composer { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; margin-bottom: 16px; box-shadow: var(--shadow); }
.composer .tabs { display: flex; border-bottom: 1px solid var(--border); }
.composer .tabs button {
  border: none; background: none; padding: 10px 15px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; font-size: 13px;
}
.composer .tabs button.on { color: var(--blue); border-bottom-color: var(--blue); }
.composer .body { padding: 12px; }
.composer textarea, .composer input[type=text] {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; outline: none; resize: vertical;
}
.composer textarea:focus, .composer input[type=text]:focus { border-color: var(--blue); }
.composer .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.composer select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; }

.tl-item { display: flex; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: none; }
.tl-ico {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; flex: none; color: #fff;
}
.tl-ico svg { width: 15px; height: 15px; }
.tl-body { flex: 1; min-width: 0; }
.tl-body .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-body .head b { font-size: 13px; }
.tl-body .head .when { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.tl-body .subj { font-weight: 600; margin-top: 2px; }
.tl-body .text { color: #334155; margin-top: 2px; white-space: pre-wrap; }
.tl-body .auto { display: inline-block; background: #ede9fe; color: #6d28d9; font-size: 10.5px; font-weight: 700; border-radius: 5px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }

/* ---- Deals board ---- */
.board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 10px; }
.col { background: #e9eef5; border-radius: var(--radius); width: 265px; min-width: 265px; padding: 10px; }
.col .col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.col .col-head .dot { width: 9px; height: 9px; border-radius: 50%; }
.col .col-head b { font-size: 13px; }
.col .col-head .sum { margin-left: auto; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.deal-card {
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow);
}
.deal-card:hover { border-color: var(--blue); }
.deal-card.dragging { opacity: .45; }
.deal-card b { display: block; font-size: 13px; }
.deal-card .val { font-weight: 700; color: var(--green); margin-top: 3px; }
.deal-card .meta { display: flex; align-items: center; gap: 7px; margin-top: 7px; color: var(--muted); font-size: 12px; }
.col.dragover { outline: 2px dashed var(--blue); outline-offset: -4px; }

/* ---- Tasks ---- */
.task-group h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.task-group h4.overdue { color: var(--red); }
.task-row { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 6px; }
.task-row:hover { border-color: var(--blue); }
.task-row input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--green); cursor: pointer; }
.task-row .t-name { font-weight: 600; }
.task-row .t-sub { color: var(--muted); font-size: 12px; }
.task-row .t-due { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.task-row .t-due.overdue { color: var(--red); font-weight: 700; }
.task-row.done .t-name { text-decoration: line-through; color: var(--muted); }
.task-type-ico { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.task-type-ico svg { width: 14px; height: 14px; }

/* ---- Calendar ---- */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cal-head h3 { font-size: 16px; min-width: 160px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.cal-dow { background: #f8fafc; padding: 7px; text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.cal-cell { background: #fff; min-height: 96px; padding: 6px; font-size: 12px; }
.cal-cell.dim { background: #f8fafc; color: var(--muted); }
.cal-cell .dnum { font-weight: 700; margin-bottom: 4px; }
.cal-cell.today .dnum { color: #fff; background: var(--blue); border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.cal-ev { background: #e0eaff; color: var(--blue-dark); border-radius: 5px; padding: 2px 6px; margin-bottom: 3px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.cal-ev.task-ev { background: #fef3c7; color: #92400e; }

/* ---- Plans ---- */
.plan-step { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.plan-step:last-child { border: none; }
.plan-step .day-chip { background: var(--navy); color: #fff; border-radius: 8px; padding: 4px 9px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.step-editor { display: grid; grid-template-columns: 70px 110px 1fr auto; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.step-editor input, .step-editor select, .step-editor textarea { padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; width: 100%; }

/* ---- Reports ---- */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-row .lbl { width: 130px; min-width: 130px; font-size: 12.5px; font-weight: 600; text-align: right; color: #475569; }
.bar-row .bar-track { flex: 1; background: #eef2f7; border-radius: 6px; height: 22px; position: relative; }
.bar-row .bar { height: 100%; border-radius: 6px; background: var(--blue); min-width: 2px; }
.bar-row .val { font-size: 12px; font-weight: 700; color: var(--muted); min-width: 60px; }

/* ---- Modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow: auto; }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 100%; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.modal.wide { width: 760px; }
.modal .m-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal .m-head h3 { font-size: 16px; flex: 1; }
.modal .m-body { padding: 20px; max-height: 70vh; overflow: auto; }
.modal .m-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; outline: none; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }

/* ---- Toast ---- */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--navy); color: #fff; border-radius: 10px; padding: 11px 16px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: slidein .18s ease-out;
}
.toast.err { background: var(--red); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Inbox ---- */
.inbox-item { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); cursor: pointer; background: #fff; }
.inbox-item:hover { background: #f0f6ff; }
.inbox-item .ib-body { flex: 1; min-width: 0; }
.inbox-item .ib-head { display: flex; gap: 8px; align-items: baseline; }
.inbox-item .ib-head .when { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.inbox-item .ib-text { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 5px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }

code.api { background: var(--navy); color: #a5f3fc; display: block; padding: 14px; border-radius: 8px; font-size: 12px; overflow-x: auto; white-space: pre; font-family: Consolas, monospace; }
