/* Newguard Builder — the inbox
   The header button, the sheet it drops, the @ menu a note opens, and the
   task list inside the CRM's lead drawer. Same daylight-glass system as the
   rest: glass over the periwinkle ground, hairline borders, pill controls,
   the slow-hover / instant-press / spring-release contract, and nothing that
   snaps. A deadline is the one place another hue appears — amber as it comes
   close, danger red once it has passed, since a late job is the only thing
   here that is genuinely wrong. */

/* ---- the header button ----
   A plain glass pill with a count chip that fits the button's own line box
   (never stretches it past the controls beside it). When something is unread
   the chip breathes — once the panel has been opened it settles. */
.ib-btn { position: relative; }
.ib-btn .ib-count {
  background: rgba(76, 99, 230, .14); border: 1px solid rgba(76, 99, 230, .3); color: var(--accent-deep);
  font: 700 10.5px var(--sans); letter-spacing: .04em; line-height: 15px; padding: 0 6px;
  min-width: 19px; border-radius: 999px; text-align: center;
  transition: background .3s var(--ease-out), color .3s var(--ease-out), border-color .3s var(--ease-out);
}
.ib-btn.has-new .ib-count {
  background: var(--cta-grad); border-color: transparent; color: var(--on-cta);
  animation: ib-breathe 2.6s var(--ease-out) infinite;
}
@keyframes ib-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(76, 99, 230, .45); }
  50% { box-shadow: 0 0 0 5px rgba(76, 99, 230, 0); }
}

/* ---- the sheet ----
   The right-click menu's glass, sized for reading: it hangs off the button it
   was opened from and clamps itself into the window. */
.ib-panel {
  position: fixed; z-index: 62; width: min(420px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 96px));
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 18px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5);
  box-shadow: 0 18px 48px rgba(24, 33, 66, .22), 0 2px 10px rgba(24, 33, 66, .1), inset 0 1px 0 rgba(255, 255, 255, .9);
  animation: ib-in .2s var(--ease-out) both;
}
.ib-panel.closing { animation: ib-out .16s var(--ease-out) both; pointer-events: none; }
@keyframes ib-in { from { opacity: 0; transform: translateY(-7px) scale(.975); } }
@keyframes ib-out { to { opacity: 0; transform: translateY(-5px) scale(.985); } }

.ib-head { display: flex; align-items: center; gap: 9px; padding: 12px 10px 11px 16px; border-bottom: 1px solid var(--line-soft); flex: none; }
.ib-head > b { font: 700 14px var(--display); letter-spacing: -.01em; margin-right: auto; }
.ib-tabs .btn { padding: 4px 10px; font-size: 11.5px; }
.ib-head .btn.icon { width: 26px; height: 26px; padding: 0; display: grid; place-items: center; }
.ib-head .btn.icon svg { width: 14px; height: 14px; }

.ib-list { flex: 1; min-height: 0; overflow-y: auto; padding: 7px; display: flex; flex-direction: column; gap: 4px; }
.ib-group {
  font: 700 10px var(--sans); letter-spacing: .11em; text-transform: uppercase; color: var(--muted);
  padding: 10px 9px 4px;
}
.ib-none { margin: 0; padding: 22px 20px 26px; font-size: 12.75px; color: var(--muted); text-align: center; line-height: 1.6; }
.ib-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none;
  padding: 9px 14px 10px; border-top: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--muted);
}
.ib-foot .linkish { color: var(--accent-deep); font-size: 11.5px; }
.ib-foot .linkish:hover { color: var(--accent); }

/* ---- one item ---- */
.ib-item {
  position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px 10px;
  border: 1px solid transparent; border-radius: 13px; background: transparent; cursor: pointer;
  transition: background .16s var(--ease-out), border-color .16s var(--ease-out),
    transform .28s var(--ease-spring), opacity .18s var(--ease-out);
  animation: ib-row-in .28s var(--ease-out) both;
}
.ib-item.settled { animation: none; }
@keyframes ib-row-in { from { opacity: 0; transform: translateY(-5px); } }
.ib-item.leaving { opacity: 0; transform: translateX(10px); }
.ib-item:hover { background: rgba(255, 255, 255, .8); border-color: var(--line-soft); }
.ib-item:active { transform: scale(.99); transition-duration: .06s; }
.ib-item.is-new { background: rgba(76, 99, 230, .07); border-color: rgba(76, 99, 230, .18); }
.ib-item.is-new:hover { background: rgba(76, 99, 230, .11); }
.ib-item.is-new::before {
  content: ''; position: absolute; left: 3px; top: 21px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 7px rgba(76, 99, 230, .7);
}
.ib-item.is-done { opacity: .52; }
.ib-item.is-done .ib-text { text-decoration: line-through; text-decoration-color: rgba(24, 33, 66, .35); }

.ib-ico {
  flex: none; width: 26px; height: 26px; border-radius: 8px; margin-top: 1px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-deep);
}
.ib-ico svg { width: 14px; height: 14px; }
.ib-ico.mention { background: rgba(122, 95, 208, .14); color: #5B45A8; }
.ib-item.due-late .ib-ico { background: var(--danger-bg); color: var(--danger-ink); }

.ib-body { flex: 1; min-width: 0; }
.ib-text {
  margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink); word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ib-at { color: var(--accent-deep); font-weight: 700; }
.ib-at.me {
  background: rgba(76, 99, 230, .14); border-radius: 5px; padding: 0 3px; margin: 0 -1px;
}
.ib-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 3px; font-size: 11px; color: var(--muted); }
.ib-when { font-family: var(--mono); font-size: 10.5px; }
.ib-lead {
  border: 1px solid var(--line-soft); background: rgba(255, 255, 255, .7); color: var(--accent-deep);
  font: 600 10.5px var(--sans); padding: 1px 8px; border-radius: 999px; cursor: pointer; max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .16s var(--ease-out), border-color .16s var(--ease-out), color .16s var(--ease-out);
}
.ib-lead:hover { background: var(--accent-soft); border-color: rgba(76, 99, 230, .4); }

.ib-acts { display: flex; align-items: center; gap: 5px; flex: none; margin-top: 1px; }
.ib-due {
  font: 600 10.5px var(--sans); letter-spacing: .02em; white-space: nowrap;
  padding: 2px 8px; border-radius: 999px; color: var(--muted);
  background: rgba(255, 255, 255, .7); border: 1px solid var(--line-soft);
}
.ib-due.soon { color: var(--warn); border-color: rgba(154, 106, 18, .28); background: rgba(154, 106, 18, .08); }
.ib-due.today { color: var(--warn); border-color: rgba(154, 106, 18, .42); background: rgba(154, 106, 18, .14); font-weight: 700; }
.ib-due.late { color: var(--danger-ink); border-color: var(--danger-line); background: var(--danger-bg); font-weight: 700; }
.ib-item.is-done .ib-due { color: var(--muted); background: rgba(255, 255, 255, .7); border-color: var(--line-soft); font-weight: 600; }

.ib-tick, .ib-x {
  padding: 0; width: 24px; height: 24px; display: grid; place-items: center; flex: none;
  border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, .7);
  color: var(--muted); cursor: pointer;
  transition: transform .3s var(--ease-spring), background .16s var(--ease-out),
    border-color .16s var(--ease-out), color .16s var(--ease-out), opacity .16s var(--ease-out);
}
.ib-tick svg { width: 13px; height: 13px; }
.ib-x svg { width: 11px; height: 11px; }
.ib-tick:hover { background: rgba(14, 138, 95, .1); border-color: rgba(14, 138, 95, .45); color: var(--ok); transform: translateY(-1px); }
.ib-tick:active, .ib-x:active { transform: translateY(1px) scale(.94); transition-duration: .06s; }
.ib-item.is-done .ib-tick { background: rgba(14, 138, 95, .12); border-color: rgba(14, 138, 95, .4); color: var(--ok); }
.ib-x { opacity: 0; }
.ib-item:hover .ib-x, .ib-item:focus-within .ib-x { opacity: 1; }
.ib-x:hover { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-ink); }

/* ---- the toast a new item raises, wherever you are standing ---- */
.ib-dock { position: fixed; top: 74px; right: 22px; z-index: 61; display: flex; flex-direction: column; gap: 7px; align-items: flex-end; pointer-events: none; }
.ib-toast { pointer-events: auto; cursor: pointer; max-width: 340px; align-items: flex-start; }
.ib-toast .hist-mark { color: var(--accent); margin-top: 3px; }
.ib-toast.urgent .hist-mark { color: var(--warn); }
.ib-toast-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ib-toast-txt b { font-size: 12.5px; }
.ib-toast-txt span { font-size: 12px; opacity: .78; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }

/* ---- the @ menu ---- */
.ib-atmenu {
  position: fixed; z-index: 70; padding: 5px; max-height: 210px; overflow-y: auto;
  border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(22px) saturate(1.5); -webkit-backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: 0 16px 40px rgba(24, 33, 66, .2), inset 0 1px 0 rgba(255, 255, 255, .9);
  animation: ib-in .15s var(--ease-out) both;
}
.ib-atmenu.closing { animation: ib-out .13s var(--ease-out) both; pointer-events: none; }
.ib-atrow {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px;
  border: 0; border-radius: 10px; background: transparent; cursor: pointer; text-align: left;
  font: 500 12.5px var(--sans); color: var(--ink);
  transition: background .14s var(--ease-out), color .14s var(--ease-out);
}
.ib-atrow.is-on, .ib-atrow:hover { background: var(--accent-soft); color: var(--accent-deep); }
.ib-athandle { font: 700 12.5px var(--sans); }
.ib-atname { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-avatar {
  width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font: 700 9.5px var(--sans); letter-spacing: .04em; color: var(--on-cta); background: var(--user-grad);
}

/* ---- tasks inside the lead drawer ---- */
.crm-tasks { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.crm-tasks:empty { display: none; }
.crm-task {
  display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px 9px;
  background: rgba(255, 255, 255, .58); border: 1px solid var(--line-soft); border-radius: 12px;
  transition: border-color .16s var(--ease-out), background .16s var(--ease-out),
    opacity .2s var(--ease-out), transform .2s var(--ease-out);
  animation: ib-row-in .28s var(--ease-out) both;
}
.crm-task.settled { animation: none; }
.crm-task.leaving { opacity: 0; transform: translateX(8px); }
.crm-task:hover { background: rgba(255, 255, 255, .85); border-color: var(--line); }
.crm-task.is-done { opacity: .55; }
.crm-task.is-done .ib-text { text-decoration: line-through; text-decoration-color: rgba(24, 33, 66, .35); }
.crm-task .ib-body { display: flex; flex-direction: column; gap: 2px; }
.crm-task .ib-text { font-size: 12.75px; -webkit-line-clamp: 4; }
.crm-task .ib-acts { align-self: center; }
.crm-task-who {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted);
}
.crm-task-who .ib-avatar { width: 17px; height: 17px; font-size: 8px; }
.crm-task-who b { color: var(--ink); font-weight: 600; }

/* assigning one: who, by when, and what — one row of controls over the note */
.crm-assign { display: flex; flex-direction: column; gap: 8px; }
.crm-assign-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crm-assign-row select, .crm-assign-row input[type=date] {
  width: auto; flex: 0 1 auto; font-size: 12px; padding: 6px 10px; border-radius: 10px;
}
.crm-assign-row input[type=date] { color: var(--muted); }
.crm-assign-row input[type=date]:focus { color: var(--ink); }
.crm-assign-row .spacer { flex: 1; }
.crm-assign textarea { resize: vertical; min-height: 42px; font-size: 13px; }
.crm-assign .btn { flex: none; }

/* the hint under the log box: who this note is about to notify.
   It grows in rather than appearing — the box below it must not jump. */
.crm-notify {
  display: grid; grid-template-rows: 0fr; opacity: 0;
  transition: grid-template-rows .3s var(--ease-out), opacity .24s var(--ease-out);
}
.crm-notify.on { grid-template-rows: 1fr; opacity: 1; }
.crm-notify > div { overflow: hidden; min-height: 0; }
.crm-notify-in {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 10px; margin-top: 1px;
  background: var(--accent-soft); border: 1px solid rgba(76, 99, 230, .22); border-radius: 11px;
  font-size: 11.5px; color: var(--accent-deep);
}
.crm-notify-in .ib-avatar { width: 18px; height: 18px; font-size: 8px; }
.crm-notify-in label { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: var(--muted); }
.crm-notify-in input[type=date] { width: auto; font-size: 11.5px; padding: 3px 8px; border-radius: 8px; }
.crm-comm-due {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 2px;
  font: 600 10px var(--sans); letter-spacing: .02em; text-transform: none;
  padding: 1px 7px; border-radius: 999px;
  background: rgba(154, 106, 18, .1); border: 1px solid rgba(154, 106, 18, .25); color: var(--warn);
}
.crm-comm-due.late { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-ink); }
.crm-comm-due.done { background: rgba(14, 138, 95, .1); border-color: rgba(14, 138, 95, .3); color: var(--ok); }
/* the line under a note that tagged somebody */
.crm-comm-notified {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--line-soft);
  font-size: 11px; color: var(--muted);
}
.crm-comm-notified b { color: var(--accent-deep); font-weight: 600; }
.crm-comm-cleared { color: var(--ok); font-weight: 600; }

/* ---- phones ---- */
@media (max-width: 640px) {
  .ib-panel {
    top: auto !important; right: 0 !important; left: 0; bottom: 0;
    width: 100%; max-height: 82vh; max-height: 82dvh;
    border-radius: 20px 20px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: ib-sheet-in .34s var(--ease-out) both;
  }
  .ib-panel.closing { animation: ib-sheet-out .24s var(--ease-out) both; }
  @keyframes ib-sheet-in { from { transform: translateY(103%); } }
  @keyframes ib-sheet-out { to { transform: translateY(103%); } }
  .ib-dock { top: auto; bottom: 18px; left: 16px; right: 16px; align-items: stretch; }
  .ib-toast { max-width: none; }
  .ib-atmenu { max-height: 170px; }
  .crm-assign-row select, .crm-assign-row input, .crm-assign textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .ib-btn.has-new .ib-count { animation: none; }
  .ib-item:active, .ib-tick:hover, .ib-tick:active, .ib-x:active { transform: none; }
}
