:root {
  --green-dark: #005b4f;
  --green-deep: #013f38;
  --green-light: #87a651;
  --gold: #cdb069;
  --surface: #f7faf4;
  --surface-strong: #eef5e8;
  --ink: #17312d;
  --muted: #62736d;
  --line: rgba(0, 91, 79, 0.14);
  --white: #ffffff;
  --shadow: 0 24px 60px rgba(0, 43, 37, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    linear-gradient(135deg, rgba(0, 91, 79, 0.96), rgba(1, 63, 56, 0.94)),
    radial-gradient(circle at top left, rgba(205, 176, 105, 0.36), transparent 34%),
    var(--green-dark);
}

button,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.chat-panel {
  width: min(1280px, 100%);
  height: min(880px, calc(100vh - 56px));
  min-height: 620px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-view {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
}

.is-hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  color: var(--white);
  background:
    linear-gradient(90deg, var(--green-dark), var(--green-deep) 72%),
    var(--green-dark);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.brand-mark span {
  width: 24px;
  height: 30px;
  display: block;
  border-radius: 22px 22px 22px 2px;
  background: linear-gradient(145deg, var(--green-light), #b4c86f);
  transform: rotate(42deg);
  box-shadow: inset -6px -5px 0 rgba(0, 91, 79, 0.24);
}

.eyebrow {
  margin: 0 0 3px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(21px, 3vw, 34px);
  line-height: 1.05;
  letter-spacing: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.1);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.status-pill.online .status-dot {
  background: #a8d56c;
}

.status-pill.offline .status-dot {
  background: #e48770;
}

.messages {
  overflow-y: auto;
  padding: 26px;
  background:
    linear-gradient(180deg, rgba(135, 166, 81, 0.13), transparent 220px),
    var(--surface);
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  max-width: 850px;
  margin: 0 0 18px;
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 38px;
  margin-left: auto;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  font-size: 12px;
  font-weight: 800;
  background: var(--green-dark);
}

.message.user .avatar {
  grid-column: 2;
  background: var(--gold);
  color: var(--green-deep);
}

.bubble {
  min-width: 0;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 10px 28px rgba(0, 43, 37, 0.07);
}

.message.user .bubble {
  grid-column: 1;
  grid-row: 1;
  color: var(--white);
  background: var(--green-dark);
  border-color: transparent;
}

.bubble p {
  margin: 0;
  line-height: 1.55;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.quick-actions button,
.meta-toggle {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(0, 91, 79, 0.18);
  border-radius: 999px;
  color: var(--green-dark);
  cursor: pointer;
  background: var(--surface-strong);
}

.quick-actions button:hover,
.meta-toggle:hover {
  border-color: rgba(0, 91, 79, 0.42);
}

.meta {
  margin-top: 14px;
}

.meta-details {
  display: none;
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-strong);
  overflow-x: auto;
}

.meta.open .meta-details {
  display: block;
}

.meta-details pre {
  margin: 0;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.5;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--line);
  background: var(--white);
}

textarea {
  width: 100%;
  max-height: 140px;
  resize: none;
  padding: 14px 16px;
  border: 1px solid rgba(0, 91, 79, 0.24);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  background: var(--surface);
}

textarea:focus {
  border-color: var(--green-dark);
  box-shadow: 0 0 0 4px rgba(0, 91, 79, 0.12);
}

.send-button {
  min-width: 118px;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 8px;
  color: var(--white);
  cursor: pointer;
  font-weight: 800;
  background: var(--green-dark);
}

.send-button:hover {
  background: var(--green-deep);
}

.send-button:disabled {
  cursor: progress;
  opacity: 0.72;
}

.typing {
  display: inline-flex;
  gap: 5px;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-light);
  animation: pulse 1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.12s;
}

.typing span:nth-child(3) {
  animation-delay: 0.24s;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ------------------------------- painel -------------------------------- */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.tab {
  min-height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 700;
  cursor: pointer;
  background: transparent;
}

.tab.active {
  color: var(--green-deep);
  background: var(--white);
}

.panel-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.filters label {
  display: grid;
  gap: 5px;
  min-width: 150px;
}

.filters span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.filters select {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(0, 91, 79, 0.24);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  background: var(--surface);
}

.ghost-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(0, 91, 79, 0.24);
  border-radius: 8px;
  color: var(--green-dark);
  font-weight: 700;
  cursor: pointer;
  background: var(--surface-strong);
}

.panel-scroll {
  overflow-y: auto;
  padding: 22px 24px 32px;
}

.section-title {
  margin: 26px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-title:first-child {
  margin-top: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.kpi {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 8px 22px rgba(0, 43, 37, 0.05);
}

.kpi-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.kpi-value {
  margin: 0;
  font-size: clamp(20px, 2.4vw, 28px);
  font-weight: 800;
  line-height: 1.1;
  color: var(--green-deep);
}

.kpi-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.aviso {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  color: var(--ink);
  font-size: 13px;
  background: rgba(205, 176, 105, 0.14);
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 26px;
}

.card {
  margin-top: 26px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 8px 22px rgba(0, 43, 37, 0.05);
}

.two-col .card {
  margin-top: 0;
}

.card h3 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 800;
  color: var(--green-deep);
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 130px) 1fr 56px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--surface-strong);
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green-dark), var(--green-light));
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.strong {
  font-weight: 700;
}

td.danger {
  color: #a3341f;
}

tbody tr:hover {
  background: var(--surface);
}

.risco {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.risco-alto {
  color: #8d2b18;
  background: rgba(228, 135, 112, 0.24);
}

.risco-medio {
  color: #7a5c12;
  background: rgba(205, 176, 105, 0.28);
}

.risco-baixo {
  color: #2c5c22;
  background: rgba(135, 166, 81, 0.24);
}

.loading-note {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
}

.loading-note.erro {
  color: #a3341f;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 0;
  }

  .filters {
    padding: 14px 16px;
  }

  .filters label {
    min-width: 100%;
  }

  .panel-scroll {
    padding: 16px;
  }

  .bar-row {
    grid-template-columns: minmax(70px, 90px) 1fr 52px;
  }

  .chat-panel {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .messages {
    padding: 18px;
  }

  .message,
  .message.user {
    grid-template-columns: 34px minmax(0, 1fr);
    margin-left: 0;
  }

  .message.user .avatar {
    grid-column: 1;
  }

  .message.user .bubble {
    grid-column: 2;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .send-button {
    width: 100%;
  }
}
