/* =========================================================
   Contacts / Segments / Automations / Logs v2 (cr- scope)
   Builds on the sd- design kit from platform-dashboard.css
   ========================================================= */

.cr-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--sd-ink);
  max-width: min(1500px, 100%);
  width: 100%;
  margin: 0 auto;
}
.cr-kpis4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }

/* ---------- toolbar ---------- */
.cr-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.cr-search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e3e9f2;
  background: #f8fafd;
  border-radius: 10px;
  padding: 8px 12px;
  flex: 1 1 260px;
  max-width: 420px;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.cr-search:focus-within { border-color: #9dbdf5; background: #fff; box-shadow: 0 0 0 3px rgba(54, 126, 245, 0.12); }
.cr-search svg { width: 15px; height: 15px; color: #8b99ad; flex: 0 0 auto; }
.cr-search input { border: 0; outline: 0; background: transparent; font-size: 13.5px; width: 100%; color: #0f172a; }
.cr-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.cr-chip {
  border: 1px solid #e3e9f2;
  background: #fff;
  color: #5b6b82;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.14s ease;
}
.cr-chip:hover { border-color: #c9d6ea; }
.cr-chip.active { background: #0f172a; border-color: #0f172a; color: #fff; }

/* ---------- bulk bar ---------- */
.cr-bulkbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: #f2f7ff;
  border: 1px solid #cfe0fb;
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.cr-bulkbar b { margin-right: auto; color: #1e5fd6; }

/* ---------- table extras ---------- */
.cr-table .cr-cb { width: 34px; }
.cr-table input[type="checkbox"] { accent-color: #367ef5; width: 15px; height: 15px; cursor: pointer; }
.cr-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cr-person b { display: block; font-size: 13.5px; }
.cr-person small { display: block; color: #5b6b82; font-size: 12px; }
.cr-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e7f0ff, #d3e3fd);
  color: #1e5fd6;
  font-size: 11.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  letter-spacing: 0.02em;
}
.cr-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #47566d;
  background: #eef2f8;
  border-radius: 6px;
  padding: 2.5px 7px;
  margin: 1px 3px 1px 0;
}
.cr-rowact { white-space: nowrap; text-align: right; }
.cr-ic {
  border: 1px solid transparent;
  background: transparent;
  color: #7c8ba1;
  border-radius: 8px;
  padding: 5px;
  cursor: pointer;
  display: inline-flex;
  transition: all 0.13s ease;
}
.cr-ic svg { width: 15px; height: 15px; }
.cr-ic:hover { background: #eef2f8; color: #0f172a; }
.cr-ic.danger:hover { background: rgba(220, 38, 38, 0.08); color: #dc2626; }

.sd-btn.danger { color: #b32020; border-color: #f0c9c9; }
.sd-btn.danger:hover { background: rgba(220, 38, 38, 0.05); border-color: #e4a9a9; }
.sd-btn.danger-ghost { color: #b32020; }

/* ---------- cards grid (segments / automations) ---------- */
.cr-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.cr-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cr-card-top h3 { margin: 0; font-size: 15.5px; letter-spacing: -0.01em; }
.cr-desc { color: #5b6b82; font-size: 13px; margin: 6px 0 12px; min-height: 18px; }
.cr-seg-count { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.cr-seg-count b { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.cr-seg-count span { color: #5b6b82; font-size: 12.5px; }
.cr-rules-sum { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; }
.cr-rules-sum code {
  font-size: 11.5px;
  background: #f6f8fc;
  border: 1px solid #e9eef6;
  border-radius: 7px;
  padding: 4px 8px;
  color: #47566d;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.cr-card-actions { display: flex; gap: 6px; margin-top: 10px; }
.cr-auto-meta { display: flex; flex-wrap: wrap; gap: 10px; color: #47566d; font-size: 12.5px; margin-bottom: 10px; }
.cr-auto-meta svg { width: 13px; height: 13px; vertical-align: -2px; color: #b48b0e; }

/* recipes */
.cr-recipes { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin-top: 6px; }
.cr-recipe {
  text-align: left;
  border: 1px dashed #c9d6ea;
  background: #fbfcfe;
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: all 0.15s ease;
}
.cr-recipe:hover { border-color: #367ef5; background: #f4f8ff; transform: translateY(-2px); }
.cr-recipe b { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: #0f172a; }
.cr-recipe b svg { width: 14px; height: 14px; color: #b48b0e; }
.cr-recipe span { color: #5b6b82; font-size: 12.5px; }
.cr-recipe small { color: #8b99ad; font-size: 11.5px; }

/* ---------- logs console ---------- */
.cr-loglist { display: flex; flex-direction: column; border: 1px solid #e9eef6; border-radius: 12px; overflow: hidden; }
.cr-log { border-bottom: 1px solid #eef2f8; background: #fff; }
.cr-log:last-child { border-bottom: 0; }
.cr-log-line {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
  font-size: 12.5px;
  min-width: 0;
}
.cr-log-line:hover { background: #f7faff; }
.cr-log-chev svg { width: 13px; height: 13px; color: #a9b6c9; transition: transform 0.15s ease; }
.cr-log.open .cr-log-chev svg { transform: rotate(90deg); }
.cr-lvl {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  border-radius: 5px;
  padding: 2.5px 6px;
  flex: 0 0 auto;
}
.cr-lvl.info { color: #1e5fd6; background: rgba(54, 126, 245, 0.1); }
.cr-lvl.success { color: #147c3d; background: rgba(22, 163, 74, 0.1); }
.cr-lvl.error { color: #b32020; background: rgba(220, 38, 38, 0.1); }
.cr-lvl.warn { color: #955f0d; background: rgba(217, 155, 32, 0.14); }
.cr-log-event {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: #0f172a;
  background: #f3f6fb;
  border-radius: 6px;
  padding: 2.5px 7px;
  white-space: nowrap;
}
.cr-log-msg { color: #47566d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0; }
.cr-log-line time { color: #8b99ad; font-size: 11.5px; flex: 0 0 auto; }
.cr-log-json {
  margin: 0;
  padding: 12px 14px 14px 35px;
  background: #0e1526;
  color: #d7e3f6;
  font-size: 11.5px;
  line-height: 1.55;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- modal ---------- */
.cr-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: crFade 0.16s ease;
}
@keyframes crFade { from { opacity: 0; } to { opacity: 1; } }
.cr-modal-card {
  background: #fff;
  border-radius: 18px;
  width: min(480px, 100%);
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.28);
  animation: crPop 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.cr-modal-card.wide { width: min(620px, 100%); }
@keyframes crPop { from { transform: translateY(10px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.cr-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #eef2f8;
}
.cr-modal-head h3 { margin: 0; font-size: 16.5px; letter-spacing: -0.01em; }
.cr-x { border: 0; background: #f3f6fb; color: #5b6b82; border-radius: 9px; padding: 7px; cursor: pointer; display: inline-flex; }
.cr-x svg { width: 14px; height: 14px; }
.cr-x:hover { background: #e8edf5; color: #0f172a; }
.cr-modal-body { padding: 18px 20px 20px; overflow-y: auto; }

/* ---------- forms ---------- */
.cr-form { display: flex; flex-direction: column; gap: 12px; }
.cr-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 700; color: #47566d; }
.cr-form label small { font-weight: 500; color: #8b99ad; }
.cr-form input, .cr-form select, .cr-textarea {
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: #0f172a;
  background: #fff;
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
  width: 100%;
}
.cr-form input:focus, .cr-form select:focus, .cr-textarea:focus {
  border-color: #9dbdf5;
  box-shadow: 0 0 0 3px rgba(54, 126, 245, 0.12);
}
.cr-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cr-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.cr-help { margin: 0 0 10px; color: #5b6b82; font-size: 13px; }
.cr-help code { background: #f3f6fb; border-radius: 5px; padding: 1px 5px; font-size: 12px; }
.cr-file { margin-bottom: 8px; font-size: 13px; }
.cr-textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* rules builder */
.cr-rules-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #47566d; margin-top: 2px; }
.cr-rules { display: flex; flex-direction: column; gap: 8px; }
.cr-rule { display: grid; grid-template-columns: 1.1fr 1.1fr 1fr auto; gap: 7px; align-items: center; }
.cr-rule select, .cr-rule input { padding: 8px 10px; font-size: 12.5px; }
.cr-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f2f7ff;
  border: 1px solid #cfe0fb;
  color: #1e5fd6;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
}
.cr-preview svg { width: 15px; height: 15px; }
.cr-preview b { font-size: 15px; }

/* console density */
.cr-console .cr-toolbar { margin-bottom: 12px; }

@media (max-width: 900px) {
  .cr-kpis4 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .cr-rule { grid-template-columns: 1fr 1fr; }
  .cr-rule input { grid-column: 1 / -2; }
}

/* ---------- Domains v2 (dm-) ---------- */
.dm-list { display: flex; flex-direction: column; gap: 12px; }
.dm-card { padding: 16px 18px; }
.dm-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dm-ident { display: flex; align-items: center; gap: 12px; min-width: 220px; flex: 1 1 220px; }
.dm-ico { width: 38px; height: 38px; border-radius: 12px; background: rgba(54,126,245,.09); color: #1e5fd6; display: inline-flex; align-items: center; justify-content: center; }
.dm-ico svg { width: 18px; height: 18px; }
.dm-ident b { display: block; font-size: 14.5px; letter-spacing: -0.01em; }
.dm-ident small { display: block; color: var(--sd-mut); font-size: 12px; margin-top: 1px; }
.dm-auth { display: flex; gap: 5px; flex-wrap: wrap; }
.dm-actions { display: flex; gap: 7px; margin-left: auto; flex-wrap: wrap; }
.dm-dns { border-top: 1px solid #eef2f8; margin-top: 14px; padding-top: 14px; }
.dm-recs { border: 1px solid #e9eef6; border-radius: 12px; overflow: hidden; }
.dm-rec { display: grid; grid-template-columns: 64px 1.2fr 1.8fr auto 34px; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid #eef2f8; font-size: 12.5px; }
.dm-rec:last-child { border-bottom: 0; }
.dm-rec-head { background: #f8fafd; color: #8b99ad; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.dm-rec code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: #33415a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-type { font-weight: 800; font-size: 11px; color: #1e5fd6; background: rgba(54,126,245,.09); border-radius: 6px; padding: 3px 8px; width: max-content; }
@media (max-width: 900px) { .dm-rec { grid-template-columns: 56px 1fr auto; } .dm-rec code.dm-val, .dm-rec-head span:nth-child(3) { display: none; } }

/* ---------- API keys v2 (ak-) ---------- */
.ak-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: #5b6b82; }
.ak-revoked td > *:not(.cr-rowact) { opacity: .62; }
.ak-auth { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ak-auth h3 { margin: 0 0 4px; font-size: 15px; }
.ak-auth p { margin: 0; color: var(--sd-mut); font-size: 13px; max-width: 72ch; }
.ak-auth code { background: #f3f6fb; border-radius: 6px; padding: 2px 7px; font-size: 12px; }
.ak-menu { position: fixed; z-index: 240; width: 190px; background: #fff; border: 1px solid var(--sd-line); border-radius: 12px; box-shadow: 0 16px 40px rgba(15,23,42,.16); padding: 5px; }
.ak-menu button { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: transparent; border-radius: 8px; padding: 9px 10px; font-size: 13px; font-weight: 600; color: var(--sd-ink); cursor: pointer; text-align: left; }
.ak-menu button svg { width: 15px; height: 15px; color: #7c8ba1; }
.ak-menu button:hover { background: #f3f6fb; }
.ak-menu button.danger { color: #b32020; } .ak-menu button.danger svg { color: #b32020; }
.ak-secret { display: flex; align-items: center; gap: 10px; background: #f8fafd; border: 1px solid #e7edf6; border-radius: 12px; padding: 12px 14px; }
.ak-secret code { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: #0f172a; word-break: break-all; }

/* ---------- Activity detail timeline (act-) ---------- */
.act-tl { display: flex; align-items: center; gap: 6px; }
.act-tl-step { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 62px; }
.act-tl-step i { width: 26px; height: 26px; border-radius: 50%; border: 1.8px solid #cdd8e8; display: inline-flex; align-items: center; justify-content: center; background: #fff; }
.act-tl-step i svg { width: 13px; height: 13px; color: #fff; }
.act-tl-step span { font-size: 11px; font-weight: 700; color: #8b99ad; }
.act-tl-step.done i { background: #16a34a; border-color: #16a34a; }
.act-tl-step.done span { color: #147c3d; }
.act-tl-step.fail i { background: #dc2626; border-color: #dc2626; }
.act-tl-step.fail span { color: #b32020; }
.act-tl-bar { flex: 1 1 auto; height: 2px; background: #e6ecf5; border-radius: 2px; }

/* ---------- Analytics stage detail (an2-) ---------- */
.an2-card { overflow: hidden; padding: 0; width: min(430px, 100%); }
.an2-hero { position: relative; padding: 26px 24px 22px; color: #fff; }
.an2-hero small { display: block; font-size: 10.5px; font-weight: 800; letter-spacing: .12em; opacity: .85; }
.an2-hero h3 { margin: 4px 0 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; color: #fff; }
.an2-ico { position: absolute; right: 56px; top: 22px; font-size: 30px; opacity: .9; }
.an2-x { position: absolute; right: 14px; top: 14px; background: rgba(255,255,255,.18); color: #fff; border: 0; }
.an2-x:hover { background: rgba(255,255,255,.3); color: #fff; }
.an2-card .cr-modal-body { padding: 20px 22px 22px; }
.an2-nums { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.an2-nums b { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.an2-nums span { color: var(--sd-mut, #5b6b82); font-size: 13px; font-weight: 600; }
