:root {
  --green-dark: #006b3f;
  --green-mid: #19a64a;
  --blue-dark: #0b2a4a;
  --blue-mid: #1f63b5;
  --yellow: #f2b705;
  --bg: #f4f7f6;
  --white: #ffffff;
  --ink: #103222;
  --muted: #5d7186;
  --line: #dbe7e2;
  --danger: #b42318;
  --success: #087a33;
  --shadow: 0 18px 45px rgba(11, 42, 74, 0.12);
  --soft-shadow: 0 10px 28px rgba(11, 42, 74, 0.1);
  --sidebar-width: 220px;
  --font-xs: 11px;
  --font-sm: 12px;
  --font-md: 14px;
  --font-lg: 18px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --radius-sm: 8px;
  --radius-md: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 94% 7%, rgba(242, 183, 5, 0.24), transparent 12rem),
    linear-gradient(135deg, #f8fbfa 0%, var(--bg) 48%, #edf5f1 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button, input, textarea, select { font: inherit; }

.hidden { display: none !important; }
.nav-item.hidden,
.nav-item[hidden] { display: none !important; }

svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(150deg, rgba(0, 107, 63, 0.92), rgba(11, 42, 74, 0.94)),
    var(--green-dark);
}

.login-box {
  width: min(390px, 100%);
  padding: 24px;
  background: var(--white);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 128px;
  display: block;
  margin: 0 auto 18px;
  border-radius: 22px;
  box-shadow: 0 10px 24px rgba(0, 107, 63, 0.16);
}

.login-copy { text-align: center; margin-bottom: 20px; }
.login-copy h1 { margin: 0; color: var(--green-dark); font-size: 25px; }
.login-copy p { margin: 6px 0 0; color: var(--yellow); font-weight: 700; }
.login-help { margin: 0 0 4px; color: var(--muted); font-size: 14px; line-height: 1.4; }

.form { display: grid; gap: 10px; }
label { font-weight: 800; color: var(--blue-dark); }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: #fff;
  color: var(--blue-dark);
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 4px rgba(25, 166, 74, 0.12);
}

textarea { resize: vertical; line-height: 1.5; min-height: 260px; }

button, .button {
  border: 0;
  border-radius: 12px;
  background: var(--panel-button, var(--green-dark));
  color: #fff;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
  font-weight: 800;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}

button:hover, .button:hover { background: var(--green-mid); transform: translateY(-1px); }

.erro { min-height: 22px; color: var(--danger); margin: 4px 0 0; font-weight: 700; }
.sucesso { min-height: 22px; color: var(--success); margin: 0; font-weight: 700; }

.app { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }

.sidebar {
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  background:
    radial-gradient(circle at 92% 77%, rgba(25,166,74,.38), transparent 9rem),
    linear-gradient(160deg, #007344 0%, #005934 58%, #06432f 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  box-shadow: 12px 0 32px rgba(0, 69, 41, 0.18);
}

.sidebar::before, .sidebar::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.sidebar::before { width: 180px; height: 180px; left: -70px; bottom: 22px; background: rgba(25,166,74,.22); }
.sidebar::after { width: 150px; height: 150px; right: -58px; bottom: 170px; background: rgba(255,255,255,.1); }

.school-brand { position: relative; z-index: 1; text-align: center; }
.school-logo {
  width: min(100%, 132px);
  max-height: 112px;
  object-fit: contain;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 16px 32px rgba(0, 40, 24, 0.25);
}
.school-brand h1 { margin: 10px 0 0; font-size: 22px; line-height: 1.1; color: #fff; }
.school-brand p { margin: 4px 0 0; color: var(--yellow); font-size: 13px; }
.brand-divider, .accent-line { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 9px; color: var(--yellow); margin-top: 7px; }
.brand-divider span, .accent-line span { height: 2px; background: currentColor; opacity: .85; }

.nav { position: relative; z-index: 2; display: grid; gap: 5px; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 3px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: #fff;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 14px;
  box-shadow: none;
}
.nav-item:hover { background: rgba(255,255,255,.12); transform: none; }
.nav-item.active { background: var(--white); color: var(--green-dark); box-shadow: 0 12px 24px rgba(0, 40, 24, .22); }
.nav-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .12);
  color: currentColor;
  flex: 0 0 auto;
  font-family: "Segoe UI Symbol", "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}
.nav-item.active .nav-icon {
  background: rgba(0, 107, 63, .1);
  color: var(--green-dark);
}
.logout { margin-top: 0; border-top: 1px solid rgba(255,255,255,.22); padding-top: 10px; }
.sidebar-mascot { position: relative; z-index: 1; width: 130px; max-width: 70%; align-self: center; margin-top: 0; filter: drop-shadow(0 10px 14px rgba(0,0,0,.18)); }

.content { min-width: 0; padding: 20px 22px 16px; position: relative; overflow: hidden; }
.content::after {
  content: "";
  position: absolute;
  right: -90px;
  top: -120px;
  width: 290px;
  height: 290px;
  border-radius: 50%;
  border: 28px solid rgba(25,166,74,.16);
  box-shadow: -28px 40px 0 rgba(242,183,5,.2);
  pointer-events: none;
}

.topbar { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.title-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #fff; color: var(--green-mid); border: 2px solid rgba(25,166,74,.22); box-shadow: var(--soft-shadow); font-family: "Segoe UI Symbol", "Segoe UI", Arial, sans-serif; font-size: 20px; font-weight: 900; line-height: 1; }
.topbar h2 { margin: 0; color: var(--green-dark); font-size: 29px; line-height: 1; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.topbar .welcome-user { margin-top: 4px; color: var(--green-dark); font-size: 12px; font-weight: 900; }

.stats { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat, .panel-card {
  background: var(--card-bg, rgba(255,255,255,.94));
  border: 1px solid rgba(214, 229, 223, .9);
  border-radius: 14px;
  box-shadow: var(--soft-shadow);
}
.stat { position: relative; min-height: 88px; display: flex; gap: 12px; align-items: center; padding: 14px; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -20px; bottom: -42px; width: 70%; height: 92px; background: rgba(25,166,74,.08); transform: rotate(-10deg); border-radius: 50%; }
.stat-blue::after { background: rgba(31,99,181,.09); }
.stat-icon { position: relative; z-index: 1; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; font-family: "Segoe UI Symbol", "Segoe UI", Arial, sans-serif; font-size: 22px; font-weight: 900; line-height: 1; background: rgba(25,166,74,.12); color: var(--green-mid); }
.stat-blue .stat-icon { background: rgba(31,99,181,.13); color: var(--blue-mid); }
.stat span { position: relative; z-index: 1; display: block; color: var(--green-dark); font-size: 14px; font-weight: 800; }
.stat-blue span { color: var(--blue-mid); }
.stat strong { position: relative; z-index: 1; display: block; margin-top: 4px; color: var(--green-dark); font-size: 34px; line-height: .9; }
.stat-blue strong { color: #06488f; }

.panel-card { padding: 14px; }
.greeting-card { position: relative; z-index: 1; display: grid; grid-template-columns: 150px minmax(0, 1fr) 72px; gap: 14px; align-items: center; margin-bottom: 14px; overflow: hidden; }
.mascot-wrap { align-self: end; display: grid; place-items: end center; min-height: 124px; border-radius: 999px 999px 14px 14px; background: linear-gradient(180deg, #eaf4ff 0%, #f6fbff 100%); overflow: hidden; }
.mascot-wrap img { width: 160px; max-width: 100%; align-self: end; }
.greeting-copy h3 { margin: 0; color: var(--green-dark); font-size: 25px; line-height: 1.1; }
.greeting-copy .role { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.accent-line { max-width: 260px; margin: 10px 0; color: var(--green-mid); }
.greeting-copy p:not(.role) { margin: 0; color: #324b66; font-size: 13px; line-height: 1.45; }
.question { display: block; margin-top: 8px; color: #087a33; font-size: 14px; }
.chat-bubble { justify-self: center; display: grid; place-items: center; width: 64px; height: 50px; border-radius: 26px 26px 26px 8px; background: #e9f2ff; color: var(--blue-mid); font-size: 21px; font-weight: 900; box-shadow: inset -6px -5px 0 rgba(31,99,181,.08); }

.database-card { position: relative; z-index: 1; display: flex; gap: 12px; align-items: center; margin-bottom: 14px; overflow: hidden; }
.database-card::after { content: ""; position: absolute; right: -60px; bottom: -70px; width: 240px; height: 150px; background: rgba(25,166,74,.08); border-radius: 100% 0 0 0; }
.db-icon { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; color: var(--green-mid); background: rgba(25,166,74,.12); font-size: 24px; }
.db-copy h3 { margin: 0; color: var(--green-dark); font-size: 18px; }
.db-copy p { margin: 4px 0 8px; color: #324b66; font-size: 12px; }
.status-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: #eaf7ed; color: #087a33; font-weight: 800; font-size: 12px; }
.status-pill i { width: 10px; height: 10px; border-radius: 50%; background: var(--green-mid); }
.db-path { color: var(--muted); font-size: 11px; word-break: break-all; }
.footer-note { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 10px; color: #0f8b3a; font-weight: 800; font-style: italic; font-size: 12px; }
.footer-note::before, .footer-note::after { content: ""; height: 1px; width: min(170px, 22vw); background: var(--line); }

.actions { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 9px; margin-bottom: 10px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--soft-shadow); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; }
th { background: #eef7f2; color: var(--green-dark); white-space: nowrap; }
td { color: #263f57; }
#view-declaracoes table { min-width: 1320px; }
#view-declaracoes th:last-child,
#view-declaracoes td:last-child {
  min-width: 390px;
  width: 390px;
}
#view-declaracoes .table-actions {
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  white-space: nowrap;
}
#view-declaracoes .table-actions button {
  flex: 0 0 auto;
  padding: 7px 9px;
  font-size: 12px;
}

.split { display: grid; grid-template-columns: minmax(230px, 330px) minmax(0, 1fr); gap: 12px; }
.message-panel h3, .editor h3 { margin: 0 0 8px; color: var(--green-dark); font-size: 18px; }
.message-list { display: grid; gap: 10px; max-height: calc(100vh - 260px); overflow: auto; padding-right: 4px; }
.message-item { display: block; width: 100%; color: var(--blue-dark); background: #f8fbfa; border: 1px solid var(--line); text-align: left; border-radius: 12px; }
.message-item:hover, .message-item.active { background: #e8f6ee; color: var(--green-dark); border-color: rgba(25,166,74,.35); transform: none; }
.editor { display: grid; gap: 7px; }
.editor button { justify-self: start; min-width: 150px; }

@media (max-width: 1120px) {
  .app { grid-template-columns: 235px minmax(0, 1fr); }
  .content { padding: 18px 18px; }
  .stats { grid-template-columns: 1fr; gap: 16px; }
  .stat { min-height: 82px; }
  .greeting-card { grid-template-columns: 135px minmax(0, 1fr); }
  .chat-bubble { display: none; }
  .greeting-copy h3 { font-size: 24px; }
}

@media (max-width: 840px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; padding: 20px; }
  .school-logo { width: 170px; }
  .school-brand h1 { font-size: 26px; }
  .sidebar-mascot { display: none; }
  .content { padding: 24px 16px; }
  .topbar h2 { font-size: 36px; }
  .topbar p { font-size: 17px; }
  .title-icon { width: 54px; height: 54px; }
  .greeting-card { grid-template-columns: 1fr; text-align: left; }
  .mascot-wrap { max-width: 280px; min-height: 210px; }
  .database-card, .actions, .split { grid-template-columns: 1fr; display: grid; }
  .footer-note::before, .footer-note::after { display: none; }
}

@media (max-width: 520px) {
  .nav-item { font-size: 16px; }
  .topbar { align-items: flex-start; gap: 14px; }
  .stats { margin-bottom: 22px; }
  .stat { padding: 20px; }
  .stat strong { font-size: 48px; }
  .greeting-copy h3 { font-size: 29px; }
  .panel-card { padding: 20px; }
}

.panel.empty-state { background: var(--white); border: 1px solid var(--line); border-radius: 22px; padding: 24px; box-shadow: var(--soft-shadow); color: var(--muted); }


.stat-yellow .stat-icon { background: rgba(242,183,5,.18); color: #9a7200; }
.stat-yellow span { color: #8a6800; }
.stat-yellow strong { color: #9a7200; }
.stat-yellow::after { background: rgba(242,183,5,.12); }
.nav-icon { font-size: 16px; }
.muted { color: var(--muted); margin: 4px 0 16px; }
.wide-editor { max-width: 980px; }
.compact-actions { grid-template-columns: minmax(220px, 360px) auto; }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.small-button, .danger-button, .copy-button {
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.small-button { background: #e8f6ee; color: var(--green-dark); }
.copy-button { background: #e9f2ff; color: var(--blue-mid); }
.danger-button { background: #fff0ed; color: var(--danger); }
.hidden-by-config { display: none !important; }
.menu-hidden .sidebar { display: none; }
.menu-hidden.app, .menu-hidden .app { grid-template-columns: 1fr; }
.show-menu-button {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 80;
  box-shadow: 0 14px 30px rgba(11, 42, 74, .22);
}
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-weight: 800; font-size: 11px; }
.badge-pendente { background: #fff6d7; color: #8a6800; }
.badge-andamento { background: #e9f2ff; color: var(--blue-mid); }
.badge-concluido { background: #e8f6ee; color: var(--green-dark); }
.resolved-row { background: #f2fbf5; }
.resolved-row td { color: #486657; }
.resolved-row td:first-child { border-left: 4px solid var(--green-mid); }
.admin-grid { display: grid; grid-template-columns: minmax(250px, 360px) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 3px 0 6px; }
.permission-grid label { display: flex; align-items: center; gap: 6px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px; background: #f8fbfa; font-size: 12px; }
.permission-grid input { width: auto; }
.compact-list { display: grid; gap: 7px; }
.compact-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; background: #f8fbfa; }
.compact-item div { min-width: 0; }
.compact-item strong, .compact-item span, .compact-item small { display: block; }
.compact-item strong { color: var(--green-dark); }
.compact-item span { color: var(--blue-dark); font-size: 13px; margin-top: 3px; }
.compact-item small { color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.section-head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-head-row h3 { margin: 0; }
.contact-report-card { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; padding: 9px; border: 1px solid rgba(25,166,74,.22); border-radius: 12px; background: #f2fbf5; }
.contact-report-card div { min-width: 0; }
.contact-report-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.contact-report-card strong { display: block; margin-top: 3px; color: var(--green-dark); overflow-wrap: anywhere; }
.contact-report-history { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-top: 10px; border-top: 1px solid rgba(25,166,74,.18); }
.contact-report-history span { width: 100%; }
.contact-report-history strong { display: inline-flex; margin: 0; padding: 6px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--blue-dark); font-size: 12px; }
.toggle-list { display: grid; gap: 12px; margin: 18px 0; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; background: #f8fbfa; border: 1px solid var(--line); border-radius: 16px; }
.toggle-row strong { color: var(--green-dark); }
.switch { position: relative; width: 58px; height: 32px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; inset: 0; }
.slider { position: absolute; inset: 0; background: #ccd9d3; border-radius: 999px; cursor: pointer; transition: .2s; }
.slider::before { content: ""; position: absolute; width: 24px; height: 24px; left: 4px; top: 4px; background: #fff; border-radius: 50%; box-shadow: 0 2px 7px rgba(0,0,0,.25); transition: .2s; }
.switch input:checked + .slider { background: var(--green-mid); }
.switch input:checked + .slider::before { transform: translateX(26px); }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(11,42,74,.48); padding: 18px; }
.modal-card { width: min(860px, 100%); max-height: 88vh; overflow: auto; background: var(--white); border-radius: 24px; box-shadow: 0 28px 80px rgba(11,42,74,.32); border: 1px solid var(--line); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 22px; background: #f8fbfa; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; color: var(--green-dark); }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 50%; background: var(--green-dark); color: #fff; font-size: 24px; line-height: 1; }
.modal-body { display: grid; gap: 12px; padding: 22px; }
.modal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.declaration-modal-card { width: min(980px, 100%); }
.modal-protocol {
  display: inline-flex;
  align-items: center;
  margin: 8px 0 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: #e8f6ee;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 900;
}
.declaration-view {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfa 100%);
}
.declaration-section {
  border: 1px solid rgba(0, 107, 63, .16);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(11, 42, 74, .08);
}
.declaration-section h4 {
  margin: 0 0 12px;
  color: var(--green-dark);
  font-size: 16px;
}
.declaration-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}
.declaration-field {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f4f7f6;
  border: 1px solid rgba(214, 229, 223, .9);
}
.declaration-field span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.declaration-field strong {
  display: block;
  margin-top: 4px;
  color: var(--blue-dark);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.document-box {
  display: grid;
  gap: 12px;
  justify-items: start;
}
.document-preview-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 55vh;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f8fbfa;
  box-shadow: 0 12px 26px rgba(11, 42, 74, .12);
}
.document-file-box {
  padding: 14px;
  border-radius: 14px;
  background: #f4f7f6;
  border: 1px dashed rgba(0, 107, 63, .28);
}
.declaration-modal-actions {
  position: sticky;
  bottom: 0;
  margin: 0;
  padding: 14px 22px 20px;
  background: #fff;
  border-top: 1px solid var(--line);
}
.field-full { grid-column: 1 / -1; }
.message-list::-webkit-scrollbar { width: 8px; }
.message-list::-webkit-scrollbar-thumb { background: rgba(0,107,63,.25); border-radius: 999px; }
@media (max-width: 840px) {
  .modal-grid { grid-template-columns: 1fr; }
  .declaration-fields { grid-template-columns: 1fr; }
  .declaration-modal-actions { flex-direction: column; }
  .declaration-modal-actions button { width: 100%; }
  .compact-actions { grid-template-columns: 1fr; }
  .table-actions { min-width: 210px; }
  .admin-grid { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns: 1fr; }
  .section-head-row { align-items: stretch; flex-direction: column; }
  .contact-report-card { grid-template-columns: 1fr; }
  .settings-shell,
  .settings-grid,
  .preview-shell {
    grid-template-columns: 1fr;
  }
  .settings-preview {
    position: static;
  }
}


.conversation-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 10px;
}

.conversation-kpi {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--soft-shadow);
}

.conversation-kpi span,
.conversation-kpi small {
  display: block;
  color: var(--muted);
}

.conversation-kpi strong {
  display: block;
  margin: 5px 0 3px;
  color: var(--green-dark);
  font-size: 18px;
  line-height: 1.1;
}

.conversation-actions {
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
}

.conversation-shell {
  display: grid;
  grid-template-columns: minmax(220px, 270px) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.conversation-list {
  max-height: calc(100vh - 205px);
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 4px 4px 4px 0;
}

.conversation-item {
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 9px;
  background: var(--white);
  color: var(--blue-dark);
  border: 1px solid var(--line);
  border-radius: 11px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(11, 42, 74, 0.06);
}

.conversation-item:hover,
.conversation-item.active {
  background: #e8f6ee;
  border-color: rgba(25,166,74,.35);
  color: var(--green-dark);
  transform: none;
}

.conversation-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.conversation-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-preview {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.conversation-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
}

.chat-panel {
  min-height: 440px;
  display: grid;
  grid-template-rows: auto auto minmax(190px, 1fr) auto;
  gap: 8px;
  min-width: 0;
}

.chat-panel.chat-internal-scroll {
  height: min(570px, calc(100vh - 120px));
  min-height: 420px;
}

.chat-panel.chat-internal-scroll .chat-messages {
  min-height: 0;
  max-height: none;
}

.chat-panel.chat-page-scroll {
  height: auto;
}

.chat-panel.chat-page-scroll .chat-messages {
  min-height: 240px;
  max-height: none;
}

.chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.chat-head > div:first-child {
  min-width: 0;
}

.chat-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 650px;
}

.chat-head-actions button {
  min-height: 28px;
  padding: 6px 8px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: none;
}

.chat-head h3 {
  margin: 0;
  color: var(--green-dark);
  font-size: 17px;
}

.chat-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.chat-messages {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 6px 5px;
  background: var(--chat-bg, linear-gradient(180deg, #f8fbfa, #eef7f2));
  border: 1px solid var(--line);
  border-radius: 11px;
}

.report-panel {
  margin-bottom: 18px;
}

.report-panel summary {
  cursor: pointer;
  color: var(--green-dark);
  font-weight: 900;
  margin-bottom: 12px;
}

.report-panel .copy-button {
  margin-top: 12px;
}

.new-chat-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 18px;
  align-items: start;
}

.new-chat-shell .editor {
  max-width: none;
}

.new-chat-help {
  display: grid;
  gap: 12px;
  color: var(--blue-dark);
}

.new-chat-help h3 {
  margin: 0;
  color: var(--green-dark);
}

.new-chat-help p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: min(78%, 720px);
  gap: 5px;
}

.chat-message.out {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message.in {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-bubble-text {
  padding: 8px 10px;
  border-radius: 11px;
  line-height: 1.4;
  font-size: 13px;
  white-space: pre;
  word-break: normal;
  box-shadow: 0 8px 18px rgba(11,42,74,.08);
}

.chat-message.in .chat-bubble-text {
  background: var(--bubble-in, var(--white));
  color: var(--blue-dark);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}

.chat-message.out .chat-bubble-text {
  background: var(--bubble-out, var(--green-dark));
  color: #fff;
  border-bottom-right-radius: 5px;
}

.chat-message time {
  color: var(--muted);
  font-size: 11px;
}

.chat-message.out time {
  color: #4b6b55;
}

.chat-form {
  display: grid;
  gap: 7px;
}

/* Conversas: leitura confortavel sem afetar as outras abas. */
#view-conversas {
  font-family: "Segoe UI", Inter, Arial, sans-serif;
}

#view-conversas .conversation-shell {
  grid-template-columns: minmax(250px, 315px) minmax(0, 1fr);
  gap: 16px;
}

#view-conversas .conversation-list {
  max-height: calc(100vh - 230px);
  gap: 9px;
  padding: 3px 8px 3px 0;
}

#view-conversas .conversation-item {
  padding: 13px 14px;
  border-radius: 16px;
  border-color: #d7e7df;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 24px rgba(11, 42, 74, .07);
}

#view-conversas .conversation-item.active {
  background: #f0fbf4;
  border-color: rgba(25, 166, 74, .5);
  box-shadow: 0 14px 30px rgba(0, 107, 63, .13);
}

#view-conversas .conversation-item strong {
  font-size: 15px;
  color: #063f2a;
}

#view-conversas .conversation-preview {
  font-size: 13px;
  line-height: 1;
  color: #516878;
}

#view-conversas .conversation-meta {
  padding-top: 2px;
  font-size: 12px;
  color: #66798a;
}

#view-conversas .chat-panel {
  min-height: 590px;
  height: min(760px, calc(100vh - 135px));
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .98);
}

#view-conversas .chat-head {
  align-items: center;
  gap: 14px;
  padding: 0 0 14px;
  border-bottom: 1px solid #dce9e4;
}

#view-conversas .chat-contact {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

#view-conversas .chat-avatar {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #006b3f, #19a64a);
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0;
  box-shadow: 0 10px 22px rgba(0, 107, 63, .22);
}

#view-conversas .chat-head h3 {
  font-size: 20px;
  line-height: 1.15;
  color: #053b29;
}

#view-conversas .chat-head p {
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.35;
  color: #5a7083;
}

#view-conversas .chat-head-actions {
  gap: 8px;
}

#view-conversas .chat-head-actions button {
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
}

#view-conversas #conversa-status {
  font-size: 12px;
  padding: 6px 10px;
}

#view-conversas .contact-report-card {
  padding: 12px;
  border-radius: 16px;
  background: #f5fcf7;
}

#view-conversas .chat-messages {
  min-height: 0;
  overflow-y: auto;
  gap: 14px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid #d9e9e2;
  background:
    linear-gradient(180deg, rgba(255,255,255,.76), rgba(245,250,247,.88)),
    #f6faf8;
  scroll-behavior: smooth;
}

#view-conversas .chat-message {
  max-width: min(82%, 820px);
  gap: 7px;
}

#view-conversas .chat-bubble-text {
  padding: 13px 16px;
  border-radius: 20px;
  line-height: 1.58;
  font-size: 17px;
  color: #163628;
  box-shadow: 0 10px 24px rgba(11, 42, 74, .08);
}

#view-conversas .chat-message.in .chat-bubble-text {
  background: #ffffff;
  border: 1px solid #d9e6e1;
  color: #173448;
  border-bottom-left-radius: 7px;
}

#view-conversas .chat-message.out .chat-bubble-text {
  background: #dff6e7;
  border: 1px solid #bde9cb;
  color: #073a27;
  border-bottom-right-radius: 7px;
}

#view-conversas .chat-message time {
  padding: 0 6px;
  font-size: 12px;
  line-height: 1.3;
  color: #687b8a;
}

#view-conversas .chat-message.out time {
  color: #517060;
}

#view-conversas .chat-form {
  gap: 10px;
  padding-top: 2px;
}

#view-conversas .chat-form textarea {
  min-height: 104px;
  padding: 14px 16px;
  border-radius: 16px;
  border-color: #d4e5de;
  background: #ffffff;
  color: #173448;
  font-size: 16px;
  line-height: 1.5;
}

#view-conversas .chat-form textarea::placeholder,
#view-conversas .chat-form-row input::placeholder {
  color: #758798;
}

#view-conversas .chat-form-row {
  gap: 10px;
}

#view-conversas .chat-form-row input {
  min-height: 42px;
  border-radius: 14px;
  font-size: 15px;
}

#view-conversas .chat-form-row button {
  min-height: 42px;
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 15px;
  box-shadow: 0 10px 22px rgba(0, 107, 63, .15);
}

@media (max-width: 1120px) {
  #view-conversas .conversation-shell {
    grid-template-columns: 1fr;
  }

  #view-conversas .conversation-list {
    max-height: 260px;
  }

  #view-conversas .chat-panel {
    height: min(720px, calc(100vh - 110px));
  }
}

@media (max-width: 640px) {
  #view-conversas .chat-panel {
    padding: 14px;
    border-radius: 18px;
  }

  #view-conversas .chat-head {
    align-items: flex-start;
    flex-direction: column;
  }

  #view-conversas .chat-head-actions {
    justify-content: flex-start;
  }

  #view-conversas .chat-messages {
    padding: 12px;
  }

  #view-conversas .chat-message {
    max-width: 94%;
  }

  #view-conversas .chat-bubble-text {
    font-size: 16px;
  }
}

.settings-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 12px;
  align-items: start;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px;
}

.settings-card {
  display: grid;
  gap: 7px;
}

.settings-card h3,
.settings-preview h3 {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-size: 18px;
}

.settings-card textarea {
  min-height: 96px;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.color-grid label {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbfa;
  font-size: 13px;
}

.color-grid input[type="color"] {
  height: 42px;
  padding: 4px;
}

.settings-toggles label {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbfa;
}

.settings-preview {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 14px;
}

.preview-shell {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}

.preview-sidebar {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px;
  color: #fff;
  background: var(--green-dark);
}

.preview-sidebar img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
}

.preview-sidebar strong,
.preview-sidebar span {
  overflow-wrap: anywhere;
}

.preview-sidebar span {
  color: rgba(255,255,255,.78);
  font-size: 12px;
}

.preview-main {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.preview-header {
  color: var(--blue-dark);
  font-size: 20px;
  font-weight: 900;
}

.preview-main button {
  justify-self: start;
  min-width: auto;
  padding: 8px 10px;
}

.preview-chat {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  background: var(--chat-bg, #f4f7f6);
}

.preview-bubble {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 14px;
  color: var(--blue-dark);
  font-size: 13px;
}

.preview-bubble.received { background: var(--bubble-in, #fff); }
.preview-bubble.sent { justify-self: end; background: var(--bubble-out, #e8f6ee); }

.preview-robot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.preview-robot img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.preview-robot p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.settings-actions {
  display: grid;
  gap: 10px;
}

.chat-compacta .conversation-shell { grid-template-columns: minmax(200px, 245px) minmax(0, 1fr); }
.chat-ampla .conversation-shell { grid-template-columns: minmax(270px, 360px) minmax(0, 1fr); }

.chat-form textarea {
  min-height: 64px;
}

.chat-form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.chat-form-row input {
  flex: 1 1 260px;
}

.chat-form-row button {
  flex: 0 0 auto;
}

@media (max-width: 1120px) {
  .conversation-status-grid { grid-template-columns: 1fr; }
  .conversation-shell { grid-template-columns: 1fr; }
  .new-chat-shell { grid-template-columns: 1fr; }
  .conversation-list { max-height: 310px; }
  .chat-panel { min-height: 560px; }
  .chat-head {
    flex-direction: column;
    align-items: stretch;
  }
  .chat-head-actions {
    justify-content: flex-start;
    max-width: none;
  }
}

@media (max-width: 840px) {
  .conversation-actions { grid-template-columns: 1fr; }
  .chat-message { max-width: 92%; }
}


.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.26); border-radius: 999px; }
.nav-item[data-view="conversas"] { border-color: rgba(242,183,5,.5); }
.nav-item[data-view="conversas"] .nav-icon { color: var(--yellow); }
.nav-item[data-view="conversas"].active .nav-icon { color: var(--green-dark); }

@media (max-height: 820px) and (min-width: 841px) {
  .sidebar { padding-top: 14px; padding-bottom: 14px; gap: 9px; }
  .school-logo { width: 108px; max-height: 92px; border-radius: 14px; }
  .school-brand h1 { font-size: 20px; margin-top: 8px; }
  .school-brand p { font-size: 12px; }
  .brand-divider { margin-top: 8px; }
  .nav { gap: 4px; }
  .nav-item { min-height: 34px; padding: 6px 8px; font-size: 13px; }
  .sidebar-mascot { display: none; }
}


.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  margin-bottom: 6px;
}

.status-button {
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.status-button.pending { background: #fff6d7; color: #8a6800; }
.status-button.wait { background: #e9f2ff; color: var(--blue-mid); }
.status-button.done { background: #e8f6ee; color: var(--green-dark); }
.status-button:hover { transform: translateY(-1px); filter: brightness(.98); }

/* Conversas compactas: prioriza o chat em zoom 100%, sem mudar a logica. */
.app {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  padding: 12px 14px;
  gap: var(--space-sm);
}

.school-logo {
  width: min(100%, 108px);
  max-height: 92px;
  border-radius: 14px;
}

.school-brand h1 {
  margin-top: 7px;
  font-size: 18px;
}

.school-brand p {
  font-size: var(--font-xs);
}

.brand-divider {
  margin-top: 5px;
  gap: 6px;
}

.nav {
  gap: 3px;
}

.nav-item {
  gap: 7px;
  border-radius: 9px;
  font-size: 12px;
  padding: 6px 8px;
}

.nav-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 13px;
}

.sidebar-mascot {
  width: 96px;
}

.content:has(#view-conversas:not(.hidden)) {
  height: 100vh;
  overflow: hidden;
  padding: 12px 14px;
}

.content:has(#view-conversas:not(.hidden))::after {
  display: none;
}

.content:has(#view-conversas:not(.hidden)) .topbar {
  margin-bottom: 8px;
  gap: 8px;
}

.content:has(#view-conversas:not(.hidden)) .title-icon {
  width: 32px;
  height: 32px;
  font-size: 16px;
}

.content:has(#view-conversas:not(.hidden)) .topbar h2 {
  font-size: 22px;
}

.content:has(#view-conversas:not(.hidden)) .topbar p {
  margin-top: 2px;
  font-size: var(--font-xs);
}

#view-conversas {
  height: calc(100vh - 68px);
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 7px;
  overflow: hidden;
  font-size: var(--font-md);
}

#view-conversas .conversation-status-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 0;
}

#view-conversas .conversation-kpi {
  padding: 7px 9px;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 16px rgba(11, 42, 74, .07);
}

#view-conversas .conversation-kpi span,
#view-conversas .conversation-kpi small {
  font-size: var(--font-xs);
  line-height: 1.25;
}

#view-conversas .conversation-kpi strong {
  margin: 2px 0 1px;
  font-size: var(--font-lg);
}

#view-conversas .conversation-actions {
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  gap: 6px;
  margin-bottom: 0;
  align-items: center;
}

#view-conversas .conversation-actions input {
  min-height: 32px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
}

#view-conversas .conversation-actions button,
#view-conversas .conversation-actions .button {
  min-height: 32px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  white-space: nowrap;
}

#view-conversas .report-panel {
  margin-bottom: 0;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 16px rgba(11, 42, 74, .06);
}

#view-conversas .report-panel summary {
  margin-bottom: 0;
  font-size: var(--font-sm);
}

#view-conversas .conversation-shell {
  min-height: 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 9px;
  align-items: stretch;
  overflow: hidden;
}

#view-conversas .conversation-list {
  height: 100%;
  max-height: none !important;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 6px;
  padding: 0 5px 0 0;
  align-content: start;
}

#view-conversas .conversation-item {
  padding: 8px 9px;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 15px rgba(11, 42, 74, .06);
}

#view-conversas .conversation-item-head {
  gap: 6px;
}

#view-conversas .conversation-item strong {
  font-size: var(--font-sm);
}

#view-conversas .conversation-preview {
  font-size: var(--font-xs);
  line-height: 1.3;
  -webkit-line-clamp: 2;
}

#view-conversas .conversation-meta {
  font-size: 10px;
}

#view-conversas .chat-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 7px;
  padding: 10px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, .98);
}

#view-conversas .chat-head {
  align-items: center;
  gap: 8px;
  padding: 0 0 7px;
}

#view-conversas .chat-contact {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

#view-conversas .chat-avatar {
  width: 34px;
  height: 34px;
  font-size: var(--font-xs);
}

#view-conversas .chat-head h3 {
  font-size: 16px;
  line-height: 1.15;
}

#view-conversas .chat-head p {
  margin-top: 2px;
  font-size: var(--font-xs);
  line-height: 1.25;
}

#view-conversas .chat-head-actions {
  gap: 5px;
  flex-wrap: wrap;
}

#view-conversas .chat-head-actions button,
#view-conversas #conversa-status {
  min-height: 26px;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
}

#view-conversas .contact-report-card {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  padding: 7px;
  border-radius: var(--radius-md);
}

#view-conversas .contact-report-card span {
  font-size: 10px;
}

#view-conversas .contact-report-card strong {
  font-size: var(--font-xs);
}

#view-conversas .contact-report-history {
  gap: 5px;
  padding-top: 6px;
}

#view-conversas .contact-report-history strong {
  padding: 4px 7px;
  font-size: 10px;
}

#view-conversas .chat-messages {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 9px;
  padding: 12px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.64), rgba(242,248,245,.92)),
    #f2f7f4;
  scroll-behavior: smooth;
}

#view-conversas .chat-message {
  max-width: min(82%, 760px);
  gap: 4px;
}

#view-conversas .chat-bubble-text {
  padding: 9px 12px;
  border-radius: 15px;
  line-height: 1.45;
  font-size: 14px;
  color: #163628;
  box-shadow: 0 7px 16px rgba(11, 42, 74, .06);
}

#view-conversas .chat-message.in .chat-bubble-text {
  background: #fff;
  border: 1px solid #d9e6e1;
  color: #173448;
  border-bottom-left-radius: 5px;
}

#view-conversas .chat-message.out .chat-bubble-text {
  background: #dff6e7;
  border: 1px solid #bde9cb;
  color: #073a27;
  border-bottom-right-radius: 5px;
}

#view-conversas .chat-message time {
  padding: 0 4px;
  font-size: 10px;
}

#view-conversas .chat-form {
  position: sticky;
  bottom: 0;
  z-index: 2;
  gap: 6px;
  padding-top: 6px;
  background: #fff;
  border-top: 1px solid var(--line);
}

#view-conversas .chat-form textarea {
  min-height: 62px;
  max-height: 92px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: var(--font-md);
  line-height: 1.35;
  resize: vertical;
}

#view-conversas .chat-form-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 7px;
  align-items: center;
}

#view-conversas .chat-form-row input {
  min-height: 32px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
}

#view-conversas .chat-form-row button {
  min-height: 32px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  justify-self: end;
}

/* Conversas: rolagem interna real, sem empurrar a pagina inteira. */
#view-conversas .conversation-shell,
#view-conversas .chat-panel {
  min-height: 0;
}

#view-conversas .chat-panel {
  overflow: hidden;
}

#view-conversas .chat-messages {
  min-height: 0;
  max-height: none;
  overflow-y: auto !important;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#view-conversas #conversa-status-form {
  min-height: 14px;
  font-size: var(--font-xs);
}

@media (max-width: 1366px) {
  :root { --sidebar-width: 205px; }
  .content:has(#view-conversas:not(.hidden)) { padding: 10px 12px; }
  #view-conversas { height: calc(100vh - 60px); gap: 6px; }
  #view-conversas .conversation-shell { grid-template-columns: 230px minmax(0, 1fr); }
  #view-conversas .chat-bubble-text { font-size: 13px; }
  #view-conversas .conversation-kpi small { display: none; }
}

@media (max-width: 1040px) {
  #view-conversas {
    height: auto;
    overflow: visible;
  }

  #view-conversas .conversation-shell {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  #view-conversas .conversation-list {
    height: 190px;
  }

  #view-conversas .chat-panel {
    height: min(640px, calc(100vh - 110px));
  }
}

@media (max-width: 720px) {
  #view-conversas .conversation-status-grid,
  #view-conversas .conversation-actions,
  #view-conversas .contact-report-card,
  #view-conversas .chat-form-row {
    grid-template-columns: 1fr;
  }

  #view-conversas .chat-head {
    align-items: flex-start;
    flex-direction: column;
  }

  #view-conversas .chat-head-actions {
    justify-content: flex-start;
  }

  #view-conversas .chat-message {
    max-width: 94%;
  }
}

/* Ajuste geral de layout compacto: trava a sidebar e reduz a escala visual. */
:root {
  --font-base: 14px;
  --font-small: 12px;
  --font-title: 28px;
  --sidebar-width: 230px;
  --card-padding: 16px;
  --section-gap: 14px;
  --button-padding-y: 8px;
  --button-padding-x: 14px;
}

body {
  font-size: var(--font-base);
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  width: 100%;
  overflow-x: hidden;
}

.sidebar {
  width: var(--sidebar-width) !important;
  min-width: var(--sidebar-width) !important;
  max-width: var(--sidebar-width) !important;
  flex: 0 0 var(--sidebar-width) !important;
  flex-shrink: 0 !important;
  height: 100vh;
  min-height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  align-self: stretch;
  padding: 12px 14px;
  gap: 8px;
}

.content {
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(100vw - var(--sidebar-width));
  padding: 16px 18px 14px;
  overflow-x: hidden;
}

.school-logo {
  width: min(100%, 104px);
  max-height: 86px;
  border-radius: 12px;
}

.school-brand h1 {
  margin-top: 7px;
  font-size: 18px;
  line-height: 1.08;
}

.school-brand p {
  font-size: 11px;
  line-height: 1.25;
}

.brand-divider,
.accent-line {
  margin-top: 5px;
  gap: 6px;
}

.nav {
  flex: none !important;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;
  padding-right: 3px;
}

.nav-item,
.nav-item.active,
.logout {
  height: 40px !important;
  min-height: 38px !important;
  max-height: 44px !important;
  flex: 0 0 auto !important;
  align-self: auto !important;
  display: flex !important;
  align-items: center !important;
  width: 100%;
  gap: 7px;
  padding: 7px 9px !important;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.15;
}

.nav-item.active {
  background: var(--white);
  color: var(--green-dark);
  box-shadow: 0 8px 16px rgba(0, 40, 24, .18);
}

.nav-icon {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 7px;
  font-size: 13px;
}

.logout {
  margin-top: 0;
  padding-top: 7px !important;
}

.sidebar-mascot {
  width: 88px;
  max-height: 105px;
  object-fit: contain;
  flex: 0 0 auto;
}

.topbar {
  gap: 10px;
  margin-bottom: 12px;
}

.title-icon {
  width: 34px;
  height: 34px;
  font-size: 17px;
}

.topbar h2 {
  font-size: var(--font-title);
  line-height: 1.05;
}

.topbar p {
  margin-top: 3px;
  font-size: var(--font-small);
}

.stats {
  gap: var(--section-gap);
  margin-bottom: var(--section-gap);
}

.stat {
  min-height: 76px;
  padding: 12px;
  gap: 10px;
}

.stat-icon {
  width: 36px;
  height: 36px;
  font-size: 19px;
}

.stat span {
  font-size: 12px;
}

.stat strong {
  font-size: 28px;
}

.panel-card {
  padding: var(--card-padding);
  border-radius: 12px;
}

.greeting-card {
  grid-template-columns: 128px minmax(0, 1fr) 56px;
  gap: 12px;
  margin-bottom: var(--section-gap);
}

.mascot-wrap {
  min-height: 108px;
}

.mascot-wrap img {
  width: 136px;
}

.greeting-copy h3 {
  font-size: 22px;
}

.greeting-copy .role,
.greeting-copy p:not(.role),
.question {
  font-size: 12.5px;
}

.chat-bubble {
  width: 54px;
  height: 42px;
  font-size: 18px;
}

.database-card {
  margin-bottom: var(--section-gap);
}

input,
textarea,
select {
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 10px;
  font-size: var(--font-base);
}

textarea {
  min-height: 180px;
  line-height: 1.42;
}

button,
.button {
  min-height: 34px;
  padding: var(--button-padding-y) var(--button-padding-x);
  border-radius: 10px;
  font-size: var(--font-base);
  line-height: 1.15;
}

.small-button,
.danger-button,
.copy-button,
.status-button {
  min-height: 30px;
  padding: 6px 10px;
  font-size: var(--font-small);
  border-radius: 9px;
}

.actions {
  gap: 8px;
  margin-bottom: 9px;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border-radius: 12px;
}

table {
  min-width: 720px;
}

th,
td {
  padding: 7px 8px;
  font-size: 12px;
  line-height: 1.32;
}

.table-actions {
  gap: 6px;
}

.table-actions button {
  min-height: 28px;
  padding: 5px 8px;
  font-size: 11.5px;
}

.split,
.editor-grid,
.users-grid,
.settings-shell,
.settings-grid,
.new-chat-shell {
  gap: var(--section-gap);
}

.editor,
.settings-card {
  gap: 8px;
}

.settings-shell {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(210px, 1fr));
}

.settings-card h3,
.settings-preview h3,
.message-panel h3 {
  font-size: 16px;
  margin-bottom: 6px;
}

.settings-card textarea,
#mensagens-auto-form textarea {
  min-height: 82px;
}

.color-grid {
  gap: 8px;
}

.color-grid label,
.settings-toggles label,
.toggle-row,
.compact-item {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12.5px;
}

.color-grid input[type="color"] {
  height: 34px;
}

.message-item {
  padding: 8px 10px;
  font-size: 12.5px;
  border-radius: 10px;
}

.conversation-status-grid {
  gap: 8px;
  margin-bottom: 8px;
}

.conversation-kpi {
  padding: 10px 12px;
  border-radius: 12px;
}

.conversation-kpi span,
.conversation-kpi small {
  font-size: 11px;
}

.conversation-kpi strong {
  font-size: 20px;
}

.modal-card {
  max-height: 86vh;
  border-radius: 18px;
}

.modal-head,
.modal-body {
  padding: 16px;
}

.content:has(#view-conversas:not(.hidden)) {
  height: 100vh;
  max-width: calc(100vw - var(--sidebar-width));
}

#view-conversas {
  height: calc(100vh - 58px);
}

@media (max-width: 1400px) {
  :root {
    --font-base: 13.5px;
    --font-small: 11.5px;
    --font-title: 26px;
    --sidebar-width: 230px;
    --card-padding: 14px;
    --section-gap: 12px;
    --button-padding-y: 7px;
    --button-padding-x: 12px;
  }

  .content {
    padding: 14px 16px 12px;
  }

  .school-logo {
    width: min(100%, 96px);
    max-height: 78px;
  }

  .school-brand h1 {
    font-size: 17px;
  }

  .sidebar-mascot {
    width: 76px;
  }

  .nav-item,
  .nav-item.active,
  .logout {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 42px !important;
    padding: 6px 8px !important;
  }

  .topbar {
    margin-bottom: 10px;
  }

  .greeting-card {
    grid-template-columns: 112px minmax(0, 1fr) 48px;
  }

  .mascot-wrap {
    min-height: 94px;
  }

  .mascot-wrap img {
    width: 116px;
  }

  .stat {
    min-height: 68px;
    padding: 10px;
  }

  .stat strong {
    font-size: 25px;
  }

  th,
  td {
    padding: 6px 7px;
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(190px, 1fr));
  }
}

@media (max-width: 1200px) {
  :root {
    --font-base: 13px;
    --font-small: 11px;
    --font-title: 24px;
    --sidebar-width: 230px;
    --card-padding: 12px;
    --section-gap: 10px;
  }

  .content {
    padding: 12px;
  }

  .school-brand p,
  .brand-divider,
  .sidebar-mascot {
    display: none;
  }

  .nav {
    gap: 3px;
  }

  .nav-item,
  .nav-item.active,
  .logout {
    height: 38px !important;
    font-size: 12px;
  }

  .settings-shell,
  .settings-grid,
  .split,
  .editor-grid,
  .users-grid,
  .new-chat-shell {
    grid-template-columns: 1fr;
  }

  .settings-preview {
    position: static;
  }

  #view-conversas .conversation-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (max-width: 840px) {
  .app {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto;
    min-height: auto;
    max-height: none;
  }

  .content,
  .content:has(#view-conversas:not(.hidden)) {
    max-width: 100vw;
  }
}

.global-status-alert,
.home-status-card {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.global-status-alert strong,
.home-status-card strong {
  color: var(--green-dark);
}

.global-status-alert.status-ok,
.home-status-card.status-ok,
.admin-status-card.status-ok {
  border-color: rgba(25, 166, 74, .28);
  background: #f1fbf5;
}

.global-status-alert.status-warn,
.home-status-card.status-warn,
.admin-status-card.status-warn {
  border-color: rgba(242, 183, 5, .45);
  background: #fff9e8;
}

.global-status-alert.status-error,
.home-status-card.status-error,
.admin-status-card.status-error {
  border-color: rgba(180, 35, 24, .35);
  background: #fff3f1;
}

.home-status-card {
  padding: 14px;
}

.home-status-card span,
.admin-status-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.home-status-card strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
}

.home-status-card p {
  margin: 4px 0 0;
  color: #324b66;
  font-size: 13px;
}

.simple-system-card .db-icon {
  color: var(--green-mid);
}

.admin-status-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.admin-status-card {
  display: grid;
  gap: 4px;
  min-height: 98px;
}

.admin-status-card strong {
  color: var(--green-dark);
  font-size: 20px;
}

.admin-status-card small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.admin-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-panel {
  min-width: 0;
}

.admin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.admin-panel-head h3 {
  margin: 0;
  color: var(--green-dark);
  font-size: 16px;
}

.admin-log-box,
.admin-command-box,
.admin-qr-code {
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbfa;
  color: #173448;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.admin-command-box {
  max-height: 220px;
}

.admin-qr-code {
  max-height: 180px;
  white-space: pre;
  word-break: normal;
  line-height: 1;
}

.admin-qr-compact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.admin-qr-compact small {
  color: var(--muted);
  font-size: 12px;
}

.whatsapp-qr-modal-card {
  width: min(420px, 100%);
  max-height: calc(100vh - 40px);
}

.whatsapp-qr-modal-body {
  justify-items: center;
  text-align: center;
}

.qr-modal-code {
  width: min(320px, 75vw);
  max-width: 320px;
  max-height: min(320px, 54vh);
  overflow: hidden;
  padding: 12px;
  background: #fff;
  color: #061812;
  font-size: 6px;
  line-height: 1;
  text-align: left;
}

.whatsapp-qr-connected {
  margin: 8px 0;
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 900;
}

.whatsapp-qr-instructions {
  display: grid;
  gap: 4px;
  width: 100%;
  color: var(--blue-dark);
  font-size: 13px;
}

.whatsapp-qr-instructions p {
  margin: 0;
}

.cmd-admin-panel {
  grid-column: 1 / -1;
}

.monitor-ip-panel {
  grid-column: 1 / -1;
}

.monitor-ip-actions,
.monitor-ip-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.monitor-ip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.monitor-ip-grid div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.monitor-ip-grid span,
.monitor-ip-form label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.monitor-ip-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--green-dark);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.monitor-ip-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  align-items: end;
  margin-top: 12px;
}

.monitor-ip-form label {
  text-transform: none;
}

.monitor-ip-form label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--green-dark);
}

.monitor-ip-form input[type="checkbox"] {
  width: auto;
}

.monitor-ip-history {
  margin-top: 10px;
  max-height: 180px;
}

.cmd-admin-warning {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #f2c94c;
  border-radius: 8px;
  background: #fff8df;
  color: #6b4a00;
  font-weight: 800;
}

.cmd-admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  margin-bottom: 12px;
}

.cmd-admin-grid label,
.cmd-admin-command-label {
  display: grid;
  gap: 6px;
}

.cmd-admin-grid span,
.cmd-admin-command-label span {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.cmd-admin-cwd {
  display: block;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: #173448;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.cmd-admin-command-label textarea {
  min-height: 82px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
}

.cmd-admin-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.cmd-admin-output {
  min-height: 220px;
  max-height: 360px;
  background: #071d2b;
  color: #d7fff1;
  border-color: #14384c;
}

@media (max-width: 1200px) {
  .admin-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-panels {
    grid-template-columns: 1fr;
  }

  .cmd-admin-grid {
    grid-template-columns: 1fr;
  }

  .monitor-ip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .monitor-ip-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .global-status-alert,
  .home-status-card,
  .admin-panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-status-grid {
    grid-template-columns: 1fr;
  }

  .monitor-ip-grid,
  .monitor-ip-form {
    grid-template-columns: 1fr;
  }
}

/* Sidebar fixa: a faixa verde lateral nao deve ter rolagem propria. */
@media (min-width: 841px) {
  .app {
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    position: sticky;
    top: 0;
    left: 0;
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    overflow-y: hidden !important;
    overflow-x: hidden !important;
  }

  .nav {
    flex: 0 0 auto !important;
    overflow-y: hidden !important;
    overflow-x: hidden !important;
    padding-right: 0 !important;
  }

  .content {
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
  }
}

@media (min-width: 841px) and (max-height: 820px) {
  .sidebar {
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 6px;
  }

  .school-logo {
    width: min(100%, 82px);
    max-height: 66px;
  }

  .school-brand h1 {
    font-size: 15px;
    margin-top: 5px;
  }

  .school-brand p,
  .brand-divider,
  .accent-line,
  .sidebar-mascot {
    display: none !important;
  }

  .nav {
    gap: 3px;
  }

  .nav-item,
  .nav-item.active,
  .logout {
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    padding: 5px 8px !important;
    font-size: 11.5px;
  }

  .nav-icon {
    width: 20px;
    height: 20px;
    min-width: 20px;
    font-size: 12px;
  }
}

/* Aba Conversas compacta: trava a tela e mantém o envio sempre visível. */
#view-conversas {
  height: calc(100vh - 126px);
  max-height: calc(100vh - 126px);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
}

#view-conversas .conversation-status-grid {
  flex: 0 0 auto;
  gap: 6px;
  margin-bottom: 0;
}

#view-conversas .conversation-kpi {
  min-height: 0;
  padding: 7px 9px;
  border-radius: 8px;
}

#view-conversas .conversation-kpi strong {
  margin: 2px 0 1px;
  font-size: 15px;
}

#view-conversas .conversation-kpi span,
#view-conversas .conversation-kpi small {
  font-size: 11px;
}

#view-conversas .conversation-actions {
  flex: 0 0 auto;
  grid-template-columns: minmax(170px, 1fr) auto auto auto;
  gap: 6px;
  margin: 0;
}

#view-conversas .conversation-actions input,
#view-conversas .conversation-actions button,
#view-conversas .conversation-actions .button {
  min-height: 32px;
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 12px;
}

#view-conversas .report-panel {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 8px;
}

#view-conversas .report-panel summary {
  font-size: 12px;
}

#view-conversas .conversation-shell {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  display: flex;
  gap: 9px;
  align-items: stretch;
  overflow: hidden;
}

#view-conversas .conversation-list {
  width: 280px;
  min-width: 260px;
  max-width: 300px;
  height: 100%;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 0 0 280px;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 2px 5px 2px 0;
}

#view-conversas .conversation-item {
  min-height: 46px;
  max-height: 62px;
  padding: 7px 9px;
  gap: 3px;
  border-radius: 8px;
  box-shadow: none;
}

#view-conversas .conversation-item strong {
  font-size: 13px;
}

#view-conversas .conversation-preview {
  font-size: 11px;
  line-height: 1.25;
  -webkit-line-clamp: 1;
}

#view-conversas .conversation-meta {
  padding-top: 0;
  font-size: 10px;
}

#view-conversas .chat-panel {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 6px;
  padding: 10px;
  border-radius: 10px;
}

#view-conversas .chat-head {
  flex: 0 0 auto;
  min-height: 40px;
  max-height: 62px;
  gap: 8px;
  padding: 0 0 7px;
  overflow: hidden;
}

#view-conversas .chat-contact {
  gap: 8px;
}

#view-conversas .chat-avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
  box-shadow: none;
}

#view-conversas .chat-head h3 {
  font-size: 15px;
  line-height: 1.15;
}

#view-conversas .chat-head p {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.2;
}

#view-conversas .chat-head-actions {
  gap: 5px;
}

#view-conversas .chat-head-actions button,
#view-conversas #conversa-status {
  min-height: 28px;
  padding: 5px 7px;
  border-radius: 8px;
  font-size: 11px;
}

#view-conversas .contact-report-card {
  flex: 0 0 auto;
  max-height: 66px;
  overflow: auto;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 11px;
}

#view-conversas .chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 7px;
  padding: 8px;
  border-radius: 9px;
  scroll-behavior: smooth;
}

#view-conversas .chat-message {
  max-width: min(86%, 720px);
  gap: 3px;
}

#view-conversas .chat-bubble-text {
  padding: 8px 10px;
  border-radius: 12px;
  line-height: 1.35;
  font-size: 13px;
  box-shadow: none;
}

#view-conversas .chat-message time {
  padding: 0 4px;
  font-size: 10px;
}

#view-conversas .chat-form {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 2;
  gap: 5px;
  padding: 7px 0 0;
  background: #fff;
  border-top: 1px solid var(--line);
}

#view-conversas .chat-form textarea {
  min-height: 36px;
  max-height: 66px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.3;
  resize: vertical;
}

#view-conversas .chat-form-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 6px;
}

#view-conversas .chat-form-row input {
  min-height: 34px;
  height: 34px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
}

#view-conversas .chat-form-row button {
  min-height: 34px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: none;
  white-space: nowrap;
}

#view-conversas #conversa-status-form {
  min-height: 14px;
  margin: 0;
  font-size: 11px;
  line-height: 1.2;
}

@media (max-height: 800px) {
  #view-conversas {
    height: calc(100vh - 108px);
    max-height: calc(100vh - 108px);
    gap: 5px;
  }

  #view-conversas .conversation-status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #view-conversas .conversation-kpi {
    padding: 5px 8px;
  }

  #view-conversas .conversation-kpi strong {
    font-size: 14px;
  }

  #view-conversas .report-panel {
    display: none;
  }

  #view-conversas .chat-head {
    min-height: 36px;
    max-height: 54px;
    padding-bottom: 5px;
  }

  #view-conversas .chat-messages {
    padding: 7px;
  }

  #view-conversas .chat-form {
    padding-top: 5px;
  }

  #view-conversas .chat-form textarea {
    min-height: 34px;
    max-height: 58px;
    font-size: 12px;
  }

  #view-conversas .chat-form-row input,
  #view-conversas .chat-form-row button {
    height: 32px;
    min-height: 32px;
    font-size: 12px;
  }

  #view-conversas .conversation-item {
    min-height: 42px;
    max-height: 54px;
    padding: 6px 8px;
  }
}

@media (max-width: 1120px) {
  #view-conversas {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  #view-conversas .conversation-shell {
    flex-direction: column;
    min-height: calc(100vh - 170px);
  }

  #view-conversas .conversation-list {
    width: 100%;
    max-width: none;
    min-width: 0;
    height: 170px;
    flex: 0 0 170px;
  }

  #view-conversas .chat-panel {
    min-height: 520px;
    height: calc(100vh - 220px);
  }
}

@media (max-width: 720px) {
  #view-conversas .conversation-status-grid,
  #view-conversas .conversation-actions {
    grid-template-columns: 1fr;
  }

  #view-conversas .chat-form-row {
    grid-template-columns: 1fr;
  }
}

#view-documentos-pendentes {
  position: relative;
  z-index: 1;
}

#view-base-estudantes {
  position: relative;
  z-index: 1;
}

.student-base-page {
  display: grid;
  gap: 12px;
}

.student-base-page > * {
  min-width: 0;
}

.student-base-import,
.student-base-registers {
  padding: 16px;
}

.student-base-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.student-base-heading h3 {
  margin: 0 0 3px;
  color: var(--blue-dark);
  font-size: 17px;
}

.student-base-heading p {
  margin: 0;
}

.student-base-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.student-base-actions input[type="search"] {
  width: min(420px, 52vw);
  min-width: 260px;
}

.student-base-mapping {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px;
  margin: 14px 0 10px;
}

.student-base-mapping span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7faf9;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
}

.student-base-mapping strong {
  display: inline-grid;
  width: 30px;
  height: 26px;
  place-items: center;
  border-radius: 4px;
  background: #e5f2eb;
  color: var(--green-dark);
  font-size: 12px;
}

.student-base-summary {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 10px;
}

.student-base-summary > div {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.student-base-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.student-base-summary strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: var(--blue-dark);
  font-size: 16px;
}

#base-estudantes-total {
  color: var(--green-dark);
  font-size: 28px;
  line-height: 1;
}

.student-base-management {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
}

.student-base-tool {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.student-base-tool > summary {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.student-base-tool > summary::-webkit-details-marker {
  display: none;
}

.student-base-tool > summary:hover {
  background: #f7faf9;
}

.student-base-tool[open] > summary {
  border-bottom: 1px solid var(--line);
}

.student-base-tool > summary strong,
.student-base-tool > summary small {
  display: block;
}

.student-base-tool > summary strong {
  color: var(--blue-dark);
  font-size: 14px;
}

.student-base-tool > summary small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.student-base-tool-icon {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 6px;
  background: #e5f2eb;
  color: var(--green-dark);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.student-base-tool-icon-danger {
  background: #fff0ed;
  color: var(--danger);
}

.student-base-tool-chevron {
  color: var(--muted);
  font-size: 18px;
  text-align: center;
  transition: transform 160ms ease;
}

.student-base-tool[open] .student-base-tool-chevron {
  transform: rotate(180deg);
}

.student-base-tool-body {
  padding: 14px;
}

.student-base-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.student-base-form-grid label,
.student-base-tool-body > label {
  display: grid;
  min-width: 0;
  gap: 5px;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
}

.student-base-form-grid input,
.student-base-tool-body > input[type="search"] {
  width: 100%;
  min-width: 0;
}

.student-base-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.student-base-form-actions p {
  min-width: 0;
  margin: 0;
}

.student-base-form-actions button {
  flex: 0 0 auto;
}

.student-base-remove-results {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 64px;
  max-height: 260px;
  margin-top: 10px;
  overflow-y: auto;
}

.student-base-remove-results > .muted {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #f8fbfa;
}

.student-base-remove-result {
  display: grid;
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--blue-dark);
  text-align: left;
}

.student-base-remove-result:hover {
  border-color: #8bbda1;
  background: #f7faf9;
}

.student-base-remove-result[aria-pressed="true"] {
  border-color: var(--green);
  background: #edf7f1;
  box-shadow: inset 3px 0 0 var(--green);
}

.student-base-remove-result strong,
.student-base-remove-result span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.student-base-remove-result strong {
  font-size: 13px;
}

.student-base-remove-result span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.student-base-errors {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #efb7b3;
  border-radius: 6px;
  background: #fff5f4;
  color: var(--danger);
  font-size: 12px;
}

.student-base-errors ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.student-base-preview {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.student-base-preview-heading {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.student-base-preview-heading h4 {
  margin: 0;
  color: var(--blue-dark);
  font-size: 15px;
}

.student-base-preview-heading .muted {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.student-base-preview-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.student-base-preview-summary > div {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfa;
}

.student-base-preview-summary dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.student-base-preview-summary dd {
  margin: 3px 0 0;
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 900;
}

.student-base-preview-table {
  min-width: 720px;
}

.student-base-preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.student-base-table {
  min-width: 780px;
}

.student-base-registers .table-wrap {
  margin-top: 12px;
}

@media (max-width: 900px) {
  .student-base-mapping,
  .student-base-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .student-base-management {
    grid-template-columns: minmax(0, 1fr);
  }

  .student-base-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .student-base-actions {
    justify-content: flex-start;
  }

  .student-base-actions input[type="search"] {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .student-base-mapping,
  .student-base-summary,
  .student-base-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .student-base-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .student-base-preview-heading,
  .student-base-preview-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .student-base-preview-heading .muted {
    text-align: left;
  }

  .student-base-preview-actions button {
    width: 100%;
  }

  .student-base-form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .student-base-form-actions button {
    width: 100%;
  }

  .student-base-preview-summary {
    grid-template-columns: minmax(0, 1fr);
  }
}

.documents-page {
  display: grid;
  gap: 12px;
}

.documents-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 220px) minmax(220px, 300px);
  gap: 9px;
  align-items: center;
}

.documents-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.documents-actions button,
.documents-actions .button,
.documents-actions .copy-button {
  min-height: 34px;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.documents-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
}

.documents-kpis article {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.documents-kpis span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.documents-kpis strong {
  display: block;
  margin-top: 5px;
  color: var(--green-dark);
  font-size: 28px;
  line-height: 1;
}

.documents-import-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.documents-import-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.documents-import-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.documents-import-summary span {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue-dark);
  background: #f8fbfa;
  font-size: 12px;
}

.documents-import-panel h4 {
  margin: 8px 0 4px;
  color: var(--blue-dark);
  font-size: 13px;
}

.documents-import-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--blue-dark);
  font-size: 12px;
  line-height: 1.45;
}

.documents-import-errors {
  color: var(--danger);
}

.documents-table {
  min-width: 980px;
}

.documents-table th {
  white-space: nowrap;
}

.table-sort-button {
  min-height: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--blue-dark);
  box-shadow: none;
  text-align: left;
  font-size: 12px;
}

.table-sort-button:hover,
.table-sort-button.active {
  background: transparent;
  color: var(--green-dark);
  transform: none;
}

.documents-cpf {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.documents-doc-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 260px;
}

.documents-doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 5px 7px;
  border: 1px solid #cfe2d9;
  border-radius: 8px;
  background: #f7fbf9;
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 800;
}

.documents-doc-chip span {
  overflow-wrap: anywhere;
}

.documents-doc-chip button {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 50%;
  background: #e8f6ee;
  color: var(--green-dark);
  font-size: 12px;
  line-height: 1;
}

.documents-complete-note {
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
}

.documents-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.documents-pagination label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--blue-dark);
  font-size: 12px;
}

.documents-pagination select {
  width: auto;
  min-width: 76px;
}

.document-modal-card {
  width: min(760px, 100%);
  border-radius: 12px;
}

.document-modal-body textarea {
  min-height: 100px;
}

.document-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.document-form-grid label,
.document-modal-body > label {
  display: grid;
  gap: 6px;
}

.document-checklist-fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.document-checklist-fieldset legend {
  padding: 0 6px;
  color: var(--blue-dark);
  font-weight: 900;
}

.document-checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.document-checklist label {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-height: 40px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--blue-dark);
  font-size: 12px;
  line-height: 1.3;
}

.document-checklist input {
  width: auto;
  margin-top: 2px;
  flex: 0 0 auto;
}

@media (max-width: 1000px) {
  .documents-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .documents-toolbar .documents-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .documents-kpis,
  .documents-import-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .documents-toolbar,
  .documents-kpis,
  .documents-import-summary,
  .document-form-grid,
  .document-checklist {
    grid-template-columns: 1fr;
  }

  .documents-import-head,
  .documents-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .documents-actions {
    justify-content: flex-start;
  }
}
