:root {
  --bg: #eceff1;
  --card: rgba(255, 255, 255, 0.92);
  --text: #111827;
  --muted: #6b7280;
  --border: rgba(17, 24, 39, 0.14);
  --accent: #1b7f8a;
  --danger: #dc2626;
  --ok: #16a34a;
  --late: #7c3aed;
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.14);
  --radius: 18px;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
.wrap { max-width: 1320px; margin: 0 auto; padding: 18px 18px 34px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin: 0 0 12px 0; font-weight: 650; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  background: #5aa3ad;
  color: #ffffff;
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  z-index: 20;
}
.topbarLeft, .topbarRight { display: flex; align-items: center; gap: 10px; }
.topbarCenter { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; min-width: 0; }
@media (min-width: 901px) { #sidebarToggle { display: none; } }
.profileWidget {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  max-width: 560px;
  width: 100%;
}
.search input {
  border: 0;
  background: transparent;
  padding: 0;
  height: 22px;
  color: #ffffff;
}
.search input::placeholder { color: rgba(255, 255, 255, 0.88); }
.search input:focus { outline: none; }
.who {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#profileWidget .who {
  border: 0;
  background: transparent;
  padding: 0;
}
.tabs { display: flex; gap: 10px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}
.tab.active {
  border-color: rgba(27, 127, 138, 0.40);
  background: rgba(27, 127, 138, 0.12);
}
.muted { color: var(--muted); }
.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.btn:hover { background: rgba(255, 255, 255, 0.98); }
.btn.iconBtn { padding: 8px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; }
.btn.primary {
  border-color: transparent;
  background: var(--accent);
  color: #ffffff;
}
.btn.primary:hover {
  background: #166f78;
}
.btn.action {
  border-color: rgba(27, 127, 138, 0.45);
  background: rgba(27, 127, 138, 0.14);
  color: #0f4c55;
}
.btn.action:hover {
  background: rgba(27, 127, 138, 0.22);
}
.btn.danger {
  border-color: transparent;
  background: rgba(220, 38, 38, 0.12);
  color: #7f1d1d;
}
.btn.ok {
  border-color: transparent;
  background: rgba(22, 163, 74, 0.12);
  color: #14532d;
}
.btn.late {
  border-color: transparent;
  background: rgba(124, 58, 237, 0.12);
  color: #4c1d95;
}
.topbar .btn {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}
.topbar .btn:hover { background: rgba(255, 255, 255, 0.26); }
input, select, textarea {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
textarea { min-height: 110px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 10px; }
th, td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { text-align: left; color: var(--muted); font-weight: 650; font-size: 12px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.status { font-size: 12px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--danger); }
.hidden { display: none; }
.modalRoot {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modalBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(6px);
}
.modalDialog {
  position: relative;
  width: min(980px, 100%);
  max-height: min(86vh, 860px);
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.modalTitle { font-weight: 800; }
.modalBody {
  padding: 14px;
  overflow: auto;
  background: rgba(243, 244, 246, 0.35);
}
.attKidsGrid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.attKidBtn { padding: 10px 12px; border-radius: 999px; }
.attKidBtn[disabled] { opacity: 0.6; cursor: not-allowed; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.small { font-size: 12px; }
.pageHeader { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

#messages:not(.hidden) {
  height: var(--panelH, calc(100vh - 140px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#messages:not(.hidden) .messagesLayout { flex: 1 1 auto; min-height: 0; }
#messages:not(.hidden) .messagesLeft,
#messages:not(.hidden) .messagesRight { min-height: 0; }

.messagesLayout { display: grid; grid-template-columns: 360px 1fr; gap: 12px; margin-top: 12px; min-height: 560px; }
.messagesLeft, .messagesRight {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.messagesLeft { display: flex; flex-direction: column; min-width: 0; }
.messagesLeftTop { padding: 12px; border-bottom: 1px solid var(--border); }
.messagesTabs { display: flex; gap: 8px; }
.chipBtn {
  border: 1px solid var(--border);
  background: rgba(243, 244, 246, 0.9);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.chipBtn.active { border-color: rgba(27, 127, 138, 0.45); background: rgba(27, 127, 138, 0.12); color: var(--text); }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(27, 127, 138, 0.35);
  background: rgba(27, 127, 138, 0.14);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}
.conversationList { overflow: auto; flex: 1 1 auto; }
.conversationItem {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.conversationItem:hover { background: rgba(243, 244, 246, 0.8); }
.conversationItem.active { background: rgba(27, 127, 138, 0.12); }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(243, 244, 246, 0.9);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--accent);
  flex: 0 0 auto;
  overflow: hidden;
}
.conversationMain { flex: 1 1 auto; min-width: 0; }
.conversationTitle { font-weight: 750; }
.conversationSnippet { margin-top: 2px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.messagesRight { display: flex; flex-direction: column; min-width: 0; }
.threadHeader { padding: 12px; border-bottom: 1px solid var(--border); }
.threadTitle { font-weight: 800; }
.threadSub { margin-top: 2px; font-size: 12px; color: var(--muted); }
.threadNewBanner {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(243, 244, 246, 0.90);
  display: none;
  justify-content: center;
}
.threadNewBanner:not(.hidden) { display: flex; }
.threadNewBanner .btn { width: auto; }
.threadBody { padding: 12px; overflow: auto; flex: 1 1 auto; background: rgba(243, 244, 246, 0.45); display: flex; flex-direction: column; gap: 10px; }
.bubble {
  max-width: 760px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  align-self: flex-start;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}
.bubble.me { margin-left: auto; align-self: flex-end; border-color: rgba(27, 127, 138, 0.45); background: rgba(27, 127, 138, 0.12); }
.bubble.deleted { opacity: 0.72; border-style: dashed; }
.bubbleAttachments { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.bubbleAttachments > * { max-width: 100%; }
.msgAttLink {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(243, 244, 246, 0.85);
  text-decoration: none;
  color: var(--text);
  max-width: 100%;
}
.msgAttLink:hover { border-color: rgba(27, 127, 138, 0.35); background: rgba(27, 127, 138, 0.10); }
.msgAttIcon { width: 18px; height: 18px; flex: 0 0 auto; color: rgba(20, 33, 61, 0.78); }
.msgAttIcon.pdf { color: rgba(185, 28, 28, 0.95); }
.msgAttIcon.word { color: rgba(29, 78, 216, 0.95); }
.msgAttIcon.excel { color: rgba(21, 128, 61, 0.95); }
.msgAttName { font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.composerFilesPreview { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 12px 0; }
.composerFileCard {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.88);
}
.composerFileThumb {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  overflow: hidden;
  flex: 0 0 auto;
  background: rgba(20,33,61,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}
.composerFileThumb img,
.composerFileThumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.composerFileMeta { min-width: 0; flex: 1; }
.composerFileName { font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composerFileSub { font-size: 11px; color: var(--muted); }
.composerFileRemove {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.96);
  cursor: pointer;
}
.waLightboxMedia { max-width: min(92vw, 920px); max-height: 72vh; display: block; margin: 0 auto; border-radius: 16px; background: #000; }
.waLightboxCaption { margin-top: 10px; text-align: center; font-size: 13px; color: var(--muted); }
.bubbleDeleted { margin-top: 8px; font-size: 12px; color: var(--muted); }
.bubbleMeta { margin-top: 6px; font-size: 12px; color: var(--muted); }
.bubbleMetaRow { margin-top: 6px; display: flex; justify-content: flex-end; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.ticks { font-weight: 900; letter-spacing: -1px; }
.ticks.gray { color: rgba(20, 33, 61, 0.45); }
.ticks.blue { color: rgba(27, 127, 138, 0.95); }
.bubbleActions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.bubbleBtn { padding: 8px 10px; border-radius: 12px; font-size: 12px; }
.bubbleResponse { margin-top: 8px; font-size: 12px; color: var(--muted); }
.composer { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-end; position: relative; }
.composer textarea { min-height: 44px; max-height: 180px; }
.composer .clipBtn { flex: 0 0 auto; }
.fileRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.75);
  margin-top: 8px;
}
.fileRow .btn { padding: 6px 8px; border-radius: 10px; }
@media (max-width: 900px) {
  .messagesLayout { grid-template-columns: 1fr; }
  .messagesLeft { max-height: 360px; }
}
.reportLayout { display: grid; grid-template-columns: 360px 1fr; gap: 12px; margin-top: 12px; min-height: 560px; }
.reportLeft, .reportRight {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.reportLeft { display: flex; flex-direction: column; min-width: 0; }
.reportLeftTop { padding: 12px; border-bottom: 1px solid var(--border); }
.reportChildList { overflow: auto; flex: 1 1 auto; }
.reportChildItem {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.reportChildItem:hover { background: rgba(243, 244, 246, 0.8); }
.reportChildItem.active { background: rgba(27, 127, 138, 0.12); }
.reportRight { display: flex; flex-direction: column; min-width: 0; }
.reportHeader { padding: 12px; border-bottom: 1px solid var(--border); }
.reportHeaderTitle { font-weight: 800; }
.reportHeaderSub { margin-top: 2px; font-size: 12px; color: var(--muted); }
.reportBody { padding: 12px; overflow: auto; flex: 1 1 auto; }
.segRow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.segBtn {
  border: 1px solid var(--border);
  background: rgba(243, 244, 246, 0.9);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 120px;
  text-align: center;
  font-weight: 700;
}
.segBtn.active { border-color: rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.10); }
.segBtn.mutedActive { border-color: rgba(27, 127, 138, 0.45); background: rgba(27, 127, 138, 0.12); }
.checkRow { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.checkRow label { display: inline-flex; gap: 8px; align-items: center; margin: 0; font-size: 13px; color: var(--text); }
.moodGrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.moodBtn {
  border: 1px solid var(--border);
  background: rgba(243, 244, 246, 0.9);
  color: var(--text);
  padding: 12px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  min-height: 52px;
}
.moodBtn:hover { background: rgba(243, 244, 246, 0.98); }
.moodBtn.selected { border-color: rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.10); }
.moodEmoji { font-size: 22px; filter: grayscale(1); opacity: 0.55; transition: filter 120ms ease, opacity 120ms ease; }
.moodBtn.selected .moodEmoji { filter: none; opacity: 1; }
.moodLabel { font-weight: 750; font-size: 13px; line-height: 1.15; }
@media (max-width: 520px) {
  .moodGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.mini { font-size: 12px; color: var(--muted); }
.attachmentsRow { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.attLink { font-size: 12px; color: var(--accent); text-decoration: underline; word-break: break-all; }
@media (max-width: 900px) {
  .reportLayout { grid-template-columns: 1fr; }
  .reportLeft { max-height: 360px; }
}
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.kpi { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: rgba(255, 255, 255, 0.9); }
.kpiLabel { font-size: 12px; color: var(--muted); font-weight: 650; }
.kpiValue { font-size: 26px; font-weight: 800; margin-top: 6px; }
.kpiSub { margin-top: 4px; }
.quickLinks { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.quickLinks .btn { border-radius: 999px; }

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  align-items: start;
}
.content { min-width: 0; }
.sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 90px);
  overflow: auto;
}
.sidebarBrand {
  padding: 10px 10px 12px;
}
.sidebarBrandTitle {
  font-weight: 800;
  letter-spacing: 0.2px;
}
.sidebarBrandSubtitle {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}
.sidebarHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.sidebarTitle {
  font-weight: 750;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menuItem {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  padding: 12px 12px;
  border-radius: 18px;
  cursor: pointer;
}
.menuItem:hover {
  border-color: rgba(27, 127, 138, 0.35);
  background: rgba(255, 255, 255, 0.98);
}
.menuItem.active {
  border-color: rgba(27, 127, 138, 0.45);
  background: rgba(27, 127, 138, 0.12);
}
.menuIcon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 999px;
  background: rgba(27, 127, 138, 0.14);
  color: var(--accent);
}
.icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}
.menuLabel { white-space: nowrap; }

body.sidebar-collapsed .layout { grid-template-columns: 76px 1fr; }
body.sidebar-collapsed .menuLabel { display: none; }
body.sidebar-collapsed .sidebar { padding: 10px 8px; }
body.sidebar-collapsed .menuItem { justify-content: center; padding: 10px 8px; }
body.sidebar-collapsed .sidebarTitle { display: none; }
body.sidebar-collapsed .sidebarBrandSubtitle { display: none; }

.sidebarBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.35);
  z-index: 30;
}

@media (max-width: 900px) {
  .wrap { padding: 12px 12px 24px; }
  .topbar { padding: 10px 12px; }
  .topbarCenter { justify-content: stretch; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: -290px;
    height: 100vh;
    max-height: none;
    width: 270px;
    z-index: 40;
    transition: left 180ms ease;
  }
  body.sidebar-open .sidebar { left: 12px; }
  body.sidebar-collapsed .layout { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; }
  .topbarCenter { order: 3; width: 100%; }
  .topbarRight { width: 100%; justify-content: flex-end; }
  .kpis { grid-template-columns: 1fr; }
}

.loginHero {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.loginMark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(27, 127, 138, 0.14);
}
.loginMark .icon { width: 22px; height: 22px; }
.inputGroup {
  position: relative;
  width: 100%;
}
.inputRightBtn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  padding: 7px 10px;
  border-radius: 10px;
}
.inputHasRightBtn input {
  padding-right: 64px;
}
