:root {
  /* Player / Radio Ibiza — azul dominante, rosa só no acento */
  --ri-blue-deep: #0c4a6e;
  --ri-blue: #1565c0;
  --ri-blue-mid: #2563eb;
  --ri-cyan: #38bdf8;
  --ri-pink: #c4146a;
  --ri-orange: #c4511a;
  --brand-gradient: linear-gradient(135deg, #0c4a6e 0%, #1565c0 38%, #2563eb 78%, #c4146a 100%);
  --brand-gradient-btn: linear-gradient(135deg, #0f5694 0%, #2563eb 55%, #3b82f6 85%);
  --bg: #eef4fb;
  --text: #141414;
  --muted: #5a5a5a;
  --radius: 16px;
  --nav-h: 4.25rem;
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
}

.ptr {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 0;
  overflow: hidden;
  color: var(--ri-blue);
  font-size: 0.82rem;
  font-weight: 700;
  transition: height 0.18s ease;
}

.ptr:not([hidden]) {
  display: flex;
}

.ptr.ptr-open {
  height: 3rem;
}

.ptr.ptr-loading .ptr-spinner {
  animation: ptr-spin 0.75s linear infinite;
}

.ptr-spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid rgba(21, 101, 192, 0.25);
  border-top-color: var(--ri-blue);
  border-radius: 50%;
}

@keyframes ptr-spin {
  to {
    transform: rotate(360deg);
  }
}

.main.ptr-shift {
  transition: transform 0.18s ease;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 3.25rem 0.45rem;
  padding-top: max(0.65rem, env(safe-area-inset-top));
  background: linear-gradient(180deg, #fff 0%, var(--bg) 100%);
}

.topbar-center {
  width: 100%;
  text-align: center;
}

.topbar-brand {
  margin: 0;
  font-size: clamp(1.85rem, 8vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  background: linear-gradient(
    90deg,
    #e8487a 0%,
    #f59e42 28%,
    #eab308 52%,
    #34d399 78%,
    #38bdf8 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar-screen {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}

.topbar .icon-btn {
  position: absolute;
  top: max(0.65rem, env(safe-area-inset-top));
  right: 1rem;
}

.icon-btn {
  border: 0;
  background: #fff;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 1.1rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.main {
  flex: 1;
  overflow: auto;
  padding: 0.5rem 1rem calc(var(--nav-h) + 1rem);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 520px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.5rem 1rem max(0.65rem, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 10;
}

.nav-btn {
  border: 0;
  border-radius: 14px;
  padding: 0.55rem 0.5rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  cursor: pointer;
}

.nav-btn.active {
  background: linear-gradient(135deg, rgba(21, 101, 192, 0.14), rgba(56, 189, 248, 0.12));
  color: var(--ri-blue-deep);
}

.nav-emoji {
  font-size: 1.35rem;
}

.pill-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.pill {
  border: 0;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.pill.active {
  background: var(--brand-gradient-btn);
  color: #fff;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ticket-card,
.channel-card {
  border: 0;
  width: 100%;
  text-align: left;
  padding: 1rem 1.05rem;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.ticket-card:active,
.channel-card:active {
  transform: scale(0.99);
}

.ticket-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.ticket-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.25;
}

.ticket-title-badge {
  flex-shrink: 0;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: #e53935;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 1px 5px rgba(229, 57, 53, 0.4);
}

.ticket-card.has-unread {
  box-shadow: 0 4px 20px rgba(21, 101, 192, 0.12);
  outline: 2px solid rgba(229, 57, 53, 0.2);
  outline-offset: -1px;
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-status-aberto {
  background: #e0f2fe;
  color: #0369a1;
}
.badge-status-em_andamento {
  background: #fef3c7;
  color: #b45309;
}
.badge-status-fechado {
  background: #d1fae5;
  color: #047857;
}
.badge-pri-urgente {
  background: #ffe4e6;
  color: #be123c;
}
.badge-pri-alta {
  background: #ffedd5;
  color: #c2410c;
}
.badge-pri-media {
  background: #e0f2fe;
  color: #0284c7;
}
.badge-pri-baixa {
  background: #f1f5f9;
  color: #64748b;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.fab {
  position: fixed;
  right: max(1rem, calc(50% - 250px));
  bottom: calc(var(--nav-h) + 1rem);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  font-size: 1.75rem;
  color: #fff;
  background: var(--brand-gradient);
  box-shadow: 0 8px 28px rgba(21, 101, 192, 0.45);
  cursor: pointer;
  z-index: 5;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.35);
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 max(0, env(safe-area-inset-bottom));
  pointer-events: none;
}

.overlay:not([hidden]) {
  display: flex;
  pointer-events: auto;
}

.overlay[hidden] {
  display: none !important;
}

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow: auto;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 1rem 1.1rem 1.5rem;
}

.sheet h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

.sheet label {
  display: block;
  margin-bottom: 0.85rem;
}

.sheet label span {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.sheet input,
.sheet textarea,
.sheet select {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: 0.75rem 0.85rem;
  border: 2px solid #ebe6df;
  border-radius: 12px;
}

.sheet textarea {
  min-height: 100px;
  resize: vertical;
}

.sheet-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-primary,
.btn-secondary {
  flex: 1;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.85rem;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
}

.btn-primary {
  background: var(--brand-gradient-btn);
  color: #fff;
}

.btn-secondary {
  background: #f1ede8;
  color: var(--text);
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 40vh;
}

.thread-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.channel-heading {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ri-blue-deep);
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  max-width: 100%;
}

.msg-row-mine {
  flex-direction: row-reverse;
}

.msg-body {
  flex: 1;
  min-width: 0;
  max-width: min(92%, 100%);
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  font-size: 1rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.msg-row-mine .msg-body {
  background: #fff;
}

.msg-author {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ri-blue-deep);
  margin-bottom: 0.25rem;
}

.msg-time {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.ticket-detail-title {
  margin: 0.5rem 0 0.75rem;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.25;
}

.readonly-box {
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e8e2da;
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.composer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
}

.composer input {
  flex: 1;
  font: inherit;
  font-size: 1.05rem;
  padding: 0.85rem 1rem;
  border: 2px solid #e8e2da;
  border-radius: 14px;
}

.composer button {
  border: 0;
  border-radius: 14px;
  padding: 0 1.1rem;
  font-weight: 800;
  background: var(--brand-gradient-btn);
  color: #fff;
  font-size: 1rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  color: var(--ri-blue);
  cursor: pointer;
  font-size: 1rem;
}

.channel-hash {
  color: var(--ri-cyan);
  font-weight: 800;
}

.unread-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ri-blue-mid);
  display: inline-block;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

.nav-badge {
  position: absolute;
  top: 0.15rem;
  right: 0.35rem;
  min-width: 1.1rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: #e53935;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1.2;
}

.bottom-nav .nav-btn {
  position: relative;
}

.ticket-unread {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  min-width: 1.25rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: #e53935;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
}

.ticket-card {
  position: relative;
}

.channel-card {
  position: relative;
}

.notice-bar {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  background: #e3f2fd;
  color: #0d47a1;
  font-size: 0.88rem;
  font-weight: 600;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
}

.avatar-xs {
  width: 28px;
  height: 28px;
  font-size: 0.6rem;
}

.detail-block {
  margin: 0.55rem 0;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  border: 1px solid #e8e2da;
  background: #fafafa;
}

.detail-block h3 {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 800;
}

.detail-block-tight {
  margin-top: 0.35rem;
}

.ticket-head-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.ticket-head-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
}

.people-summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  margin: 0;
  padding: 0.5rem 0;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.people-summary-label {
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ri-blue);
}

.people-summary-chevron {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}

.setor-summary {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  max-width: 28%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-stack {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  padding-left: 0.35rem;
}

.avatar-stack .avatar,
.avatar-stack .avatar-xs {
  margin-left: -0.45rem;
  box-shadow: 0 0 0 2px #fafafa;
}

.people-panel {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid #e8e2da;
}

.people-panel[hidden] {
  display: none !important;
}

.reply-form {
  margin-top: 0.5rem;
}

.reply-form textarea {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.65rem;
  border: 2px solid #e8e2da;
  border-radius: 12px;
  box-sizing: border-box;
  min-height: 3.5rem;
  resize: vertical;
}

.detail-block label span {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.detail-block input,
.detail-block textarea,
.detail-block select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border: 2px solid #e8e2da;
  border-radius: 12px;
  box-sizing: border-box;
}

.detail-block textarea {
  min-height: 5rem;
  resize: vertical;
}

.people-list {
  max-height: 180px;
  overflow: auto;
  margin-top: 0.35rem;
  border: 1px solid #e8e2da;
  border-radius: 12px;
  background: #fff;
  padding: 0 0.65rem;
}

.person-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.65rem;
  padding: 0.55rem 0;
  font-size: 0.92rem;
  width: 100%;
  border-bottom: 1px solid #f0ebe4;
  cursor: pointer;
}

.person-row:last-child {
  border-bottom: 0;
}

.person-row input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  margin: 0;
}

.person-row .person-name {
  flex: 1;
  min-width: 0;
  text-align: left;
  font-weight: 600;
}

.setor-chip {
  display: inline-block;
  margin: 0.15rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 2px solid #e0e0e0;
  background: #fff;
}

.setor-chip.on {
  border-color: #1565c0;
  background: #e3f2fd;
  color: #0d47a1;
}
