:root {
  --bg: #0b1020;
  --bg-soft: #10182f;
  --surface: rgba(255, 255, 255, 0.07);
  --surface-strong: rgba(255, 255, 255, 0.11);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f6f8ff;
  --muted: #9aa6c4;
  --blue: #5b8cff;
  --cyan: #23c5d9;
  --green: #20c997;
  --amber: #f5b84b;
  --red: #ff5d73;
  --violet: #a78bfa;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(91, 140, 255, 0.24), transparent 34rem),
    radial-gradient(circle at top right, rgba(35, 197, 217, 0.16), transparent 28rem),
    linear-gradient(135deg, var(--bg), #07101b 55%, #05070d);
  color: var(--text);
}

button, input, select { font: inherit; }
button { color: inherit; }
code { background: rgba(255,255,255,.08); padding: 2px 6px; border-radius: 8px; }

.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(5, 9, 18, 0.74); backdrop-filter: blur(16px);
  display: flex; flex-direction: column; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: white; font-weight: 800; letter-spacing: -.06em;
  box-shadow: 0 12px 26px rgba(32, 201, 151, .18);
}
.brand strong { display:block; font-size: 1rem; }
.brand small { color: var(--muted); }
.nav-list { display: grid; gap: 8px; }
.nav-item {
  border: 1px solid transparent; background: transparent; text-align: left;
  padding: 12px 14px; border-radius: 14px; cursor: pointer; color: var(--muted);
}
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(91,140,255,.25), rgba(35,197,217,.12)); border-color: var(--line); color: white; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .88rem; flex-wrap: wrap; }
.sidebar-footer a { color: var(--cyan); text-decoration: none; margin-left: auto; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 6px rgba(32,201,151,.12); }

.main { padding: 26px clamp(18px, 4vw, 48px) 48px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 18px; align-items: flex-end; margin-bottom: 24px; }
.eyebrow { color: var(--cyan); text-transform: uppercase; letter-spacing: .14em; font-size: .76rem; margin: 0 0 8px; font-weight: 800; }
h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -.06em; }
#pageSubtitle { color: var(--muted); margin: 8px 0 0; }
.topbar-actions { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; justify-content: flex-end; }
.search-box, label { display: grid; gap: 6px; color: var(--muted); font-size: .82rem; }
input, select {
  border: 1px solid var(--line); background: rgba(255,255,255,.08); color: var(--text);
  border-radius: 12px; padding: 10px 12px; min-height: 42px; outline: none;
}
input::placeholder { color: rgba(154,166,196,.55); }
select option { color: #0b1020; }

.btn { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer; font-weight: 700; background: rgba(255,255,255,.08); }
.btn:hover { transform: translateY(-1px); }
.btn.primary { border-color: transparent; background: linear-gradient(135deg, var(--blue), var(--cyan)); color: white; }
.btn.secondary { background: rgba(91,140,255,.16); }
.btn.ghost { background: transparent; }

.view { display: none; }
.view.active { display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; }
.two-one { grid-template-columns: 2fr 1fr; }
.two-two { grid-template-columns: 1fr 1fr; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi-card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.kpi-card { padding: 18px; position: relative; overflow: hidden; }
.kpi-card:after { content: ""; position: absolute; inset: auto -30px -40px auto; width: 110px; height: 110px; border-radius: 50%; background: rgba(91,140,255,.14); }
.kpi-card p { margin: 0; color: var(--muted); }
.kpi-card h2 { margin: 8px 0 2px; font-size: clamp(1.6rem, 3vw, 2.4rem); letter-spacing: -.05em; }
.kpi-card small { color: var(--muted); }
.panel { padding: 16px; min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 1.05rem; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: .88rem; }
.spread { align-items: center; }
.muted { color: var(--muted); }

.bar-chart { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 8px; min-height: 220px; padding-top: 18px; }
.bar-item { display: grid; gap: 8px; align-items: end; min-width: 0; }
.bar-stack { height: 180px; display: flex; flex-direction: column-reverse; justify-content: flex-start; border-radius: 12px; overflow: hidden; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); }
.bar-seg { min-height: 2px; }
.bar-outbound { background: var(--blue); }
.bar-inbound { background: var(--green); }
.bar-failed { background: var(--red); }
.bar-label { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.status-chart { display: grid; gap: 10px; }
.status-row { display: grid; grid-template-columns: 95px 1fr 54px; gap: 8px; align-items: center; }
.status-track { height: 12px; background: rgba(255,255,255,.07); border-radius: 999px; overflow: hidden; }
.status-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), var(--blue)); }

.table-wrap { overflow: auto; border-radius: 14px; border: 1px solid rgba(255,255,255,.08); }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid rgba(255,255,255,.08); vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; background: rgba(255,255,255,.04); }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: rgba(255,255,255,.05); }
.compact table { min-width: 520px; }
.status-chip { display: inline-flex; align-items:center; border-radius: 999px; padding: 4px 9px; font-size: .78rem; font-weight: 800; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.08); }
.status-read, .status-delivered, .status-finished { color: #8ff7d0; background: rgba(32,201,151,.12); }
.status-failed { color: #ff9cad; background: rgba(255,93,115,.13); }
.status-running, .status-queued, .status-submitted { color: #b7ccff; background: rgba(91,140,255,.13); }
.status-pending, .status-sending { color: #ffd991; background: rgba(245,184,75,.12); }
.progress { height: 10px; border-radius: 999px; background: rgba(255,255,255,.09); overflow:hidden; min-width: 110px; }
.progress > span { display:block; height:100%; border-radius:999px; background: linear-gradient(90deg, var(--green), var(--cyan)); }

.stack-list { display: grid; gap: 10px; }
.error-card, .inbound-card, .conversation-card {
  border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05); border-radius: 14px; padding: 12px;
}
.error-card strong, .inbound-card strong { display:block; }
.error-card small, .inbound-card small, .conversation-card small { color: var(--muted); }
.inbound-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.attention { border-color: rgba(255,93,115,.22); }

.controls-panel { padding: 12px; }
.filters-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filters-row label { min-width: 220px; }
.detail-panel { border-color: rgba(91,140,255,.22); }
.mini-kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.mini-kpi { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09); border-radius: 14px; padding: 12px; }
.mini-kpi span { display:block; color: var(--muted); font-size: .78rem; }
.mini-kpi strong { display:block; font-size: 1.25rem; margin-top: 6px; }
.tabs-row { display:flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.subtab { border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--muted); border-radius: 999px; padding: 8px 12px; cursor: pointer; }
.subtab.active { background: rgba(91,140,255,.2); color: white; }
.config-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
pre.json { overflow:auto; max-height: 420px; background: rgba(0,0,0,.24); border: 1px solid rgba(255,255,255,.08); padding: 14px; border-radius: 14px; color: #d7e3ff; }

.whatsapp-layout { display: grid; grid-template-columns: 340px 1fr; gap: 0; min-height: 650px; padding: 0; overflow: hidden; }
.conversation-list { border-right: 1px solid var(--line); overflow:auto; max-height: 75vh; padding: 12px; display: grid; gap: 10px; align-content: start; }
.conversation-card { cursor: pointer; }
.conversation-card:hover, .conversation-card.active { background: rgba(91,140,255,.13); border-color: rgba(91,140,255,.33); }
.chat-pane { display:grid; grid-template-rows: auto 1fr; min-width: 0; }
.chat-head { padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.chat-timeline {
  background:
    linear-gradient(rgba(5,9,18,.82), rgba(5,9,18,.82)),
    radial-gradient(circle at 20% 20%, rgba(32,201,151,.13), transparent 20rem);
  padding: 18px; overflow:auto; display:flex; flex-direction:column; gap: 10px;
}
.bubble { max-width: min(680px, 78%); border-radius: 16px; padding: 10px 12px; border:1px solid rgba(255,255,255,.08); }
.bubble.inbound { align-self:flex-start; background: rgba(255,255,255,.08); border-bottom-left-radius: 4px; }
.bubble.outbound { align-self:flex-end; background: rgba(32,201,151,.16); border-bottom-right-radius: 4px; }
.bubble small { display:block; color: var(--muted); margin-top: 6px; }

.lookup-results { display:grid; gap: 14px; }
.empty { color: var(--muted); padding: 18px; text-align:center; border:1px dashed rgba(255,255,255,.14); border-radius: 14px; }
.toast { position: fixed; right: 18px; bottom: 18px; background: #10182f; border:1px solid var(--line); padding: 12px 14px; border-radius: 14px; box-shadow: var(--shadow); }
.alert { padding: 10px 12px; border-radius: 12px; margin: 10px 0; }
.alert.danger { background: rgba(255,93,115,.13); border:1px solid rgba(255,93,115,.25); }

.login-body { display:grid; place-items:center; padding: 22px; }
.login-card { width:min(460px,100%); background: var(--surface); border:1px solid var(--line); border-radius: 24px; padding: 24px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 2rem; margin-top: 24px; }
.login-card p { color: var(--muted); }
.login-form { display:grid; gap: 12px; margin-top: 18px; }
.login-brand { margin-bottom: 8px; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; align-items: center; overflow:auto; }
  .nav-list { grid-auto-flow: column; grid-auto-columns: max-content; overflow:auto; }
  .sidebar-footer { margin-top: 0; margin-left: auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-one, .two-two { grid-template-columns: 1fr; }
  .whatsapp-layout { grid-template-columns: 1fr; }
  .conversation-list { border-right: 0; border-bottom: 1px solid var(--line); max-height: 320px; }
}
@media (max-width: 720px) {
  .topbar { align-items: stretch; flex-direction: column; }
  .topbar-actions { justify-content: stretch; }
  .global-search, .topbar-actions .btn { width: 100%; }
  .kpi-grid, .mini-kpi-grid, .config-grid { grid-template-columns: 1fr; }
  .main { padding: 18px; }
  .sidebar { padding: 16px; }
}

.interaction-panel .mini-kpi small { display:block; color: var(--muted); margin-top: 4px; font-size: .78rem; }
.interaction-grid { margin: 12px 0; }
.compact-head { margin-bottom: 8px; }
.compact-head h3 { margin: 0; font-size: .96rem; }
.rank-list { display: grid; gap: 10px; }
.rank-card { border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05); border-radius: 14px; padding: 12px; }
.rank-top { display:flex; justify-content:space-between; gap: 10px; align-items:center; }
.rank-top strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.rank-top span { color: var(--cyan); font-weight: 800; }
.rank-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; margin: 9px 0 7px; }
.rank-track span { display:block; height:100%; background: linear-gradient(90deg, var(--green), var(--cyan)); border-radius: 999px; }
.rank-card small { color: var(--muted); }
.interaction-jobs-wrap { margin-top: 12px; }

/* Interaction stats readability fixes */
.interaction-panel { overflow: hidden; }
.interaction-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}
.interaction-grid > article { min-width: 0; }
.rank-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}
.rank-card {
  min-width: 0;
  padding: 11px 12px;
}
.rank-top {
  min-width: 0;
  align-items: flex-start;
}
.rank-top strong {
  min-width: 0;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.25;
  word-break: break-word;
}
.rank-top span {
  flex: 0 0 auto;
  margin-left: 8px;
}
.rank-example {
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  margin-bottom: 4px;
  color: var(--text) !important;
  opacity: .86;
}
.rank-meta { display: block; }
.interaction-jobs-wrap table { min-width: 720px; }

@media (max-width: 980px) {
  .interaction-grid { grid-template-columns: 1fr; }
  .rank-list { max-height: none; overflow: visible; }
}

/* Robust interaction dashboard */
.interaction-kpis {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.insight-strip {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 10px;
  margin: 12px 0 14px;
}
.insight-card {
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.045);
  border-radius: 14px;
  padding: 12px;
  min-width: 0;
}
.insight-card strong { display:block; font-size: 1rem; }
.insight-card span, .insight-card small { color: var(--muted); display:block; }
.insight-card p { margin: 6px 0 0; color: #dce5ff; line-height: 1.35; }
.main-insight { background: linear-gradient(135deg, rgba(91,140,255,.18), rgba(35,197,217,.08)); }
.compact-head p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }
.rank-card { transition: border-color .15s ease, transform .15s ease; }
.rank-card:hover { border-color: rgba(35,197,217,.32); transform: translateY(-1px); }
.rank-tag {
  display: inline-flex;
  width: max-content;
  margin-bottom: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(35,197,217,.25);
  color: var(--cyan);
  background: rgba(35,197,217,.08);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 800;
}
.rank-top > div { min-width: 0; }
.rank-list::-webkit-scrollbar, .conversation-list::-webkit-scrollbar, .chat-timeline::-webkit-scrollbar { width: 8px; }
.rank-list::-webkit-scrollbar-thumb, .conversation-list::-webkit-scrollbar-thumb, .chat-timeline::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 999px; }
.rank-list::-webkit-scrollbar-track, .conversation-list::-webkit-scrollbar-track, .chat-timeline::-webkit-scrollbar-track { background: rgba(255,255,255,.04); }

/* Better WhatsApp conversation rendering */
.chat-head { color: var(--text); }
.chat-title-row { display:flex; justify-content:space-between; gap: 12px; align-items:flex-start; }
.chat-title-row strong { display:block; color: var(--text); font-size: 1rem; }
.chat-title-row small { display:block; color: var(--muted); margin-top: 2px; }
.chat-meta-row { display:flex; flex-wrap:wrap; gap: 8px; margin-top: 8px; }
.chat-meta-row span {
  color: var(--muted);
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.045);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: .76rem;
}
.bubble { box-shadow: 0 8px 28px rgba(0,0,0,.18); }
.bubble.needs-review { border-color: rgba(245,184,75,.45); }
.bubble-label {
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 800;
  margin-bottom: 6px;
}
.message-text { white-space: pre-wrap; line-height: 1.42; }
.template-card {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.16);
  border-radius: 14px;
  padding: 10px;
  min-width: min(420px, 100%);
}
.template-card-head {
  display:flex;
  justify-content:space-between;
  gap: 10px;
  color: var(--cyan);
  font-weight: 800;
  margin-bottom: 8px;
}
.template-card-head em {
  font-style: normal;
  color: var(--amber);
  font-size: .78rem;
}
.template-body { margin: 0 0 10px; line-height: 1.4; }
.template-card dl { margin: 0; display:grid; gap: 5px; }
.template-card dl div { display:grid; grid-template-columns: 70px 1fr; gap: 8px; align-items:start; }
.template-card dt { color: var(--muted); font-size: .75rem; }
.template-card dd { margin:0; word-break: break-all; }
.template-media-link {
  display:inline-flex;
  margin-top: 9px;
  color: var(--cyan);
  text-decoration: none;
  border: 1px solid rgba(35,197,217,.24);
  background: rgba(35,197,217,.08);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: .82rem;
}

@media (max-width: 1280px) {
  .interaction-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .insight-strip { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .interaction-kpis { grid-template-columns: 1fr; }
}

/* Conversation polish: deterministic avatar + richer WhatsApp cards */
.conversation-card-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: start;
  text-align: left;
}
.conversation-card-main { min-width: 0; display: block; }
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--avatar-color), rgba(255,255,255,.18));
  color: #061119;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25), 0 6px 18px rgba(0,0,0,.22);
  flex: 0 0 auto;
}
.avatar.tiny { width: 28px; height: 28px; font-size: .78rem; }
.avatar.large { width: 46px; height: 46px; font-size: 1.05rem; }
.chat-title-with-avatar { justify-content: flex-start; align-items: center; }
.chat-title-main { min-width: 0; flex: 1; }
.bubble-row { display: flex; gap: 8px; align-items: flex-end; width: 100%; }
.bubble-row.inbound { justify-content: flex-start; }
.bubble-row.outbound { justify-content: flex-end; }
.bubble-row.outbound .bubble { margin-left: auto; }
.wa-rich-card {
  display: grid;
  gap: 9px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(6, 14, 24, .34);
  border-radius: 14px;
  padding: 10px;
  min-width: min(420px, 100%);
}
.wa-header { font-weight: 850; color: var(--text); }
.wa-body { white-space: pre-wrap; line-height: 1.44; color: var(--text); }
.wa-footer { color: var(--muted); font-size: .88rem; border-top: 1px solid rgba(255,255,255,.08); padding-top: 7px; }
.wa-options { display: grid; gap: 7px; margin-top: 2px; }
.wa-option {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(35,197,217,.28);
  background: rgba(35,197,217,.08);
  color: var(--cyan);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: .88rem;
}
.wa-option strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-option small { margin: 0; color: var(--muted); font-size: .75rem; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-details { display: grid; gap: 5px; margin: 8px 0 2px; }
.rank-details span {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--muted);
  font-size: .82rem;
}
.rank-details b { color: var(--text); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 720px) {
  .conversation-card-row { grid-template-columns: 36px 1fr; }
  .avatar { width: 34px; height: 34px; }
  .wa-option { align-items: flex-start; border-radius: 12px; flex-direction: column; }
  .wa-option small { max-width: 100%; }
}

/* Final polish: readable interactions and WhatsApp-safe wrapping */
.avatar {
  background: var(--avatar-color) !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22), 0 6px 18px rgba(0,0,0,.22);
}
.bubble, .template-card, .wa-rich-card, .rank-card, .conversation-card-main, .message-text, .wa-body, .wa-header, .wa-footer, .template-card dd {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.template-card, .wa-rich-card { overflow: hidden; }
.template-card dl div { grid-template-columns: 64px minmax(0, 1fr); }
.template-media-link {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wa-body, .message-text { white-space: pre-wrap; }
.wa-option strong, .wa-option small { min-width: 0; }
.rank-details span {
  grid-template-columns: 92px minmax(0, 1fr);
  min-width: 0;
}
.rank-details em {
  font-style: normal;
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.rank-details b { white-space: nowrap; }
.rank-card { overflow: hidden; }
.rank-top > div { overflow: hidden; }
.rank-top strong { overflow-wrap: anywhere; word-break: break-word; }
@media (max-width: 720px) {
  .rank-details span { grid-template-columns: 1fr; gap: 2px; }
}

/* Template/media and interaction readability polish */
.template-card { overflow: hidden; }
.template-card dl { margin-top: 10px; }
.template-card dd, .template-card dt { overflow-wrap: anywhere; word-break: break-word; }
.template-body { margin: 0 0 8px; }
.template-media-box {
  display: grid;
  gap: 7px;
  margin: 8px 0 10px;
  border: 1px solid rgba(35,197,217,.18);
  background: rgba(5, 12, 20, .38);
  border-radius: 14px;
  padding: 8px;
  min-width: 0;
}
.template-media-box.compact { padding: 9px 10px; }
.template-media-preview {
  display: block;
  width: 100%;
  max-width: 420px;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.08);
}
.template-media-preview.video { object-fit: contain; background: #03070d; }
.template-media-link {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--cyan);
  font-weight: 800;
}
.rank-details em {
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}
