:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f6fb;
  color: #1d2736;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 20rem; }
button, input, select { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 0.55rem; padding: 0.62rem 0.9rem; background: #2486d5; color: #fff; font-weight: 650; transition: filter 0.15s, transform 0.15s; }
button:hover { filter: brightness(0.94); }
button:active { transform: translateY(1px); }
button.secondary { background: #e8eff8; color: #315474; }
button.danger { background: #d94d5c; }
button.text-button { background: transparent; padding: 0.25rem; }
.danger-text { color: #c53b4b; }
input, select { width: 100%; min-height: 2.45rem; border: 1px solid #c8d4e2; border-radius: 0.45rem; background: #fff; color: inherit; padding: 0.5rem 0.6rem; }
input:focus, select:focus { outline: 3px solid #b7ddfb; border-color: #2486d5; }
.shell { width: min(1360px, calc(100% - 2rem)); margin: 0 auto; padding: 2.25rem 0 4rem; }
.topbar, .topbar-actions, .section-heading, .list-row, .row-actions, .account-card-title, .account-card-title > div, .account-card-footer { display: flex; }
.topbar { justify-content: space-between; align-items: flex-start; gap: 2rem; margin-bottom: 1.5rem; }
.topbar-actions { gap: 0.6rem; flex-wrap: wrap; }
.eyebrow { margin: 0 0 0.35rem; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em; color: #2586d7; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.35rem; font-size: clamp(1.65rem, 4vw, 2.35rem); }
h2 { font-size: 1.1rem; margin-bottom: 0.45rem; }
.subtitle, .section-heading p { color: #6a7c93; font-size: 0.88rem; margin-bottom: 0; line-height: 1.45; }
.panel { background: #fff; border: 1px solid #e1e8f1; box-shadow: 0 0.5rem 1.5rem rgb(32 76 124 / 7%); border-radius: 1rem; padding: 1.15rem; }
.login-panel { width: min(30rem, 100%); margin: 8vh auto; }
.grid { display: grid; gap: 1rem; margin: 1rem 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.compact { grid-template-columns: 1fr auto; align-items: end; margin: 1rem 0; }
label { display: grid; gap: 0.3rem; color: #455a73; font-size: 0.82rem; font-weight: 650; }
.toggle { display: flex; align-items: center; gap: 0.45rem; min-height: 2.45rem; }
.toggle input { width: auto; min-height: 0; }
.metrics { display: grid; gap: 0.75rem; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.metric { padding: 0.9rem; border-radius: 0.8rem; background: linear-gradient(135deg, #eaf6ff, #f9fbff); border: 1px solid #d8e9fa; }
.metric strong { display: block; color: #155f9e; font-size: 1.42rem; margin-top: 0.16rem; }
.metric span { color: #5a6e8d; font-size: 0.78rem; }
.status { min-height: 1.25rem; color: #1d7b48; font-weight: 650; margin: 0.75rem 0; }
.error { color: #bd3445; min-height: 1.25rem; }
.section-heading { justify-content: space-between; align-items: flex-start; gap: 1rem; }
.chat-picker { width: min(19rem, 100%); flex-shrink: 0; }
.list, .conversation-list { display: grid; gap: 0.55rem; max-height: 21rem; overflow: auto; }
.list-row { align-items: center; justify-content: space-between; gap: 0.75rem; border-bottom: 1px solid #edf1f7; padding: 0.6rem 0; font-size: 0.9rem; }
.list-row:last-child { border-bottom: 0; }
.row-actions { gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.row-actions button { padding: 0.45rem 0.65rem; font-size: 0.78rem; }
.muted { color: #6a7c93; font-size: 0.78rem; }
.account-list { display: grid; gap: 0.85rem; margin-top: 1rem; }
.account-card { border: 1px solid #e0e8f2; background: #fbfdff; border-radius: 0.8rem; padding: 0.9rem; }
.account-card-title { justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.account-card-title > div { align-items: center; gap: 0.65rem; }
.account-card-title span { display: block; color: #6a7c93; font-size: 0.76rem; margin-top: 0.1rem; }
.account-card-title img, .avatar-placeholder { width: 2.5rem; height: 2.5rem; border-radius: 50%; object-fit: cover; }
.avatar-placeholder { display: grid; place-items: center; background: linear-gradient(135deg, #47a8f3, #2674be); color: #fff; font-size: 0.7rem; font-weight: 800; }
.tag { border-radius: 999px; padding: 0.25rem 0.5rem; background: #e1f4ff; color: #1670b4 !important; font-weight: 700; }
.account-fields { display: grid; gap: 0.65rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.account-card-footer { align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.75rem; }
.message-form { display: grid; gap: 0.75rem; grid-template-columns: 2fr 1.05fr 0.9fr 1.45fr 1.35fr auto; align-items: end; margin: 1rem 0; }
.messages { display: grid; gap: 0.6rem; max-height: 48rem; overflow: auto; }
.message-row { display: grid; grid-template-columns: 3.25rem minmax(10rem, 1fr) 10rem 6.5rem minmax(7rem, 0.7fr) auto; gap: 0.6rem; align-items: center; padding: 0.7rem; border: 1px solid #e1e9f4; border-radius: 0.75rem; }
.message-row > strong { color: #2f597c; }
.message-row label { font-size: 0.74rem; }
.message-row .direction { display: flex; align-items: center; gap: 0.3rem; }
.message-row .direction input { width: auto; min-height: 0; }
.message-media { min-width: 0; }
.media-preview { color: #1672b8; display: flex; align-items: center; gap: 0.45rem; overflow: hidden; text-decoration: none; }
.media-preview img { width: 3.5rem; height: 3.5rem; border-radius: 0.35rem; object-fit: cover; background: #eef2f6; }
.media-preview small { overflow: hidden; text-overflow: ellipsis; }
.bottom-grid { align-items: start; }
.calls-heading { margin-top: 1.25rem; }
.media-list { display: grid; gap: 0.65rem; max-height: 38rem; overflow: auto; margin-top: 0.8rem; }
.media-card { display: grid; grid-template-columns: 4.5rem 1fr; gap: 0.7rem; border-bottom: 1px solid #edf1f7; padding-bottom: 0.65rem; }
.media-card:last-child { border-bottom: 0; }
.media-card p { margin: 0.25rem 0; color: #5e7189; font-size: 0.76rem; word-break: break-word; }
.media-card button { font-size: 0.74rem; padding: 0.42rem 0.55rem; }
.media-card-thumb { display: grid; place-items: center; width: 4.5rem; height: 4.5rem; border-radius: 0.45rem; overflow: hidden; background: #edf3f8; color: #5b7190; text-decoration: none; font-size: 0.7rem; font-weight: 800; }
.media-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hidden { display: none !important; }

@media (max-width: 1160px) {
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .account-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .message-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .message-row { grid-template-columns: 3rem minmax(10rem, 1fr) 10rem 7rem auto; }
  .message-media { grid-column: 2 / -1; }
}
@media (max-width: 760px) {
  .shell { width: min(100% - 1rem, 1360px); padding-top: 1rem; }
  .topbar, .section-heading, .account-card-footer { flex-direction: column; align-items: stretch; }
  .grid.two, .form-grid, .form-grid.compact, .metrics, .message-form, .account-fields { grid-template-columns: 1fr; }
  .message-row { grid-template-columns: 1fr; }
  .message-media { grid-column: auto; }
  .chat-picker { width: 100%; }
  .list-row { align-items: flex-start; flex-direction: column; }
}
