:root {
  --bg-1: #f3fbf5;
  --bg-2: #e4f5ea;
  --tri-a: rgba(20, 152, 80, 0.12);
  --tri-b: rgba(12, 120, 62, 0.1);
  --ink: #102118;
  --ink-soft: #43614f;
  --card: #ffffff;
  --line: #c9e5d4;
  --brand: #0f8a49;
  --brand-strong: #0b6a38;
  --brand-wash: #e4f8ec;
  --warn: #e0b429;
  --danger: #bf2d2d;
  --ok: #168f47;
  --shadow: 0 16px 45px rgba(16, 48, 30, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 420px at -20% -8%, rgba(39, 161, 89, 0.18), transparent 60%),
    radial-gradient(760px 340px at 118% 3%, rgba(11, 122, 63, 0.16), transparent 58%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  position: relative;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    linear-gradient(30deg, var(--tri-a) 12%, transparent 12.5%, transparent 87%, var(--tri-a) 87.5%, var(--tri-a)),
    linear-gradient(150deg, var(--tri-a) 12%, transparent 12.5%, transparent 87%, var(--tri-a) 87.5%, var(--tri-a)),
    linear-gradient(90deg, var(--tri-b) 2%, transparent 2.5%, transparent 97%, var(--tri-b) 97.5%, var(--tri-b));
  background-size: 120px 210px;
  background-position: 0 0, 0 0, 60px 105px;
  opacity: 0.85;
}

.container {
  width: min(1320px, 94%);
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid #d8eedf;
  background: rgba(245, 253, 248, 0.86);
  backdrop-filter: blur(8px);
}

.topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong {
  display: block;
  font-family: "Sora", "Segoe UI", sans-serif;
  letter-spacing: 0.3px;
  font-size: 1.12rem;
  color: #0c6f3b;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.logo {
  height: 42px;
  width: auto;
  filter: drop-shadow(0 8px 12px rgba(16, 110, 58, 0.16));
}

.inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.main {
  padding: 22px 0 26px;
}

.footer {
  margin-top: 42px;
  border-top: 1px solid #d8eedf;
  color: var(--ink-soft);
  padding: 18px 0 28px;
  font-size: 0.93rem;
}

.card {
  background: var(--card);
  border: 1px solid #d8efe1;
  border-radius: 18px;
  padding: 20px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}

.filter-card {
  padding: 0;
  overflow: hidden;
}

.filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: clamp(1.05rem, 1.3vw, 1.35rem);
  color: #0e6a39;
}

.filter-summary::-webkit-details-marker {
  display: none;
}

.filter-summary::after {
  content: '+';
  font-size: 1.25rem;
  line-height: 1;
  color: #2f5741;
}

.filter-card[open] .filter-summary::after {
  content: '−';
}

.filter-summary-hint {
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.filter-body {
  padding: 0 20px 20px;
  border-top: 1px solid #e2efe6;
}

h2 {
  margin: 0 0 14px;
  color: #0e6a39;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: clamp(1.05rem, 1.3vw, 1.35rem);
}

label {
  display: block;
  margin-top: 11px;
  margin-bottom: 6px;
  color: #2f5741;
  font-size: 0.92rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #bfdcc9;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
  background: #fbfefc;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #1aa65b;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(29, 173, 94, 0.17);
}

textarea {
  resize: vertical;
}

.btn {
  margin-top: 12px;
  border: 1px solid #96d7b2;
  border-radius: 12px;
  background: linear-gradient(140deg, #23b265, #179455);
  color: #ffffff;
  padding: 9px 14px;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(24, 124, 72, 0.16);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.01);
  box-shadow: 0 6px 16px rgba(24, 124, 72, 0.18);
}

.btn:active {
  transform: translateY(0);
}

.btn-link {
  margin-top: 0;
  background: transparent;
  color: #0d7d42;
  padding: 0;
  text-decoration: underline;
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

/* ===== User menu (3-dots dropdown) ===== */
.user-menu-wrap {
  position: relative;
}

.btn-dots {
  background: #ffffff;
  border: 2px solid #0b6a38;
  color: #0b6a38;
  border-radius: 10px;
  padding: 5px 14px;
  font-size: 1.5rem;
  letter-spacing: 3px;
  cursor: pointer;
  line-height: 1;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
  margin-top: 0;
  box-shadow: 0 2px 8px rgba(11, 106, 56, 0.18);
}

.btn-dots:hover {
  background: #0b6a38;
  color: #ffffff;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(10, 40, 20, 0.18);
  padding: 18px 18px 14px;
  min-width: 280px;
  z-index: 300;
}

.user-menu-dropdown.is-hidden {
  display: none;
}

.user-menu-title {
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #0e6a39;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.user-menu-form label {
  color: #2f5741;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 9px;
  margin-bottom: 4px;
}

.user-menu-form input {
  padding: 9px 11px;
  font-size: 0.9rem;
}

.user-menu-form .btn {
  margin-top: 12px;
  width: 100%;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 980px) {
  .grid {
    grid-template-columns: 0.95fr 1.25fr;
  }
}

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

table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
}

thead {
  background: linear-gradient(90deg, #edf9f1, #def3e6);
}

th,
td {
  border-bottom: 1px solid #e0efe5;
  text-align: left;
  padding: 11px 10px;
  vertical-align: top;
  font-size: 0.94rem;
}

thead th {
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: #2b6949;
}

tbody tr:nth-child(even) {
  background: #fcfffd;
}

tbody tr:hover {
  background: #f2fbf6;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.25px;
  background: #ebf7ef;
  color: #1f6942;
}

.badge[data-status="Aguardando análise"] {
  background: #f8edc9;
  color: #7a5e0d;
}

.badge[data-status="Em análise"] {
  background: #d9f0ff;
  color: #1f5f89;
}

.badge[data-status="Resolvido"] {
  background: #d7f5df;
  color: #1d7a41;
}

.badge[data-status="Encerrado pela empresa"] {
  background: #ede7ff;
  color: #5b3ba8;
}

/* ===== Danger button ===== */
.btn-danger {
  background: linear-gradient(140deg, #bf2d2d, #992020);
  color: #fff;
  border-color: #992020;
}

.btn-danger:hover {
  background: linear-gradient(140deg, #a82626, #7e1a1a);
  filter: none;
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.muted {
  color: var(--ink-soft);
}

.flash {
  margin-top: 14px;
}

.alert {
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.92rem;
}

.alert.success {
  border-color: #bde8cb;
  background: #eafaf0;
  color: #195736;
}

.alert.error {
  border-color: #f0c3c3;
  background: #fff0f0;
  color: #8c2a2a;
}

.admin-screen .admin-menu {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0;
  padding: 0;
}

.admin-screen .admin-menu .btn {
  margin: 0;
  border-radius: 0;
  background: #eef9f2;
  color: #1e6d45;
  border-right: 1px solid #cbe7d5;
  box-shadow: none;
  white-space: nowrap;
  padding: 11px 16px;
}

.admin-screen .admin-menu .btn.active {
  background: #27ab63;
  color: #ffffff;
  border-color: #219758;
}

.admin-screen .admin-menu .btn:hover {
  transform: none;
  filter: none;
  background: #def2e6;
}

.admin-screen .admin-menu .btn.active:hover {
  background: #129851;
}

.admin-panel.is-hidden {
  display: none;
}

.admin-table {
  min-width: 1220px;
}

.actions-cell {
  width: 340px;
  min-width: 340px;
}

.admin-action-form {
  display: grid;
  gap: 8px;
}

.admin-action-form .btn {
  margin-top: 0;
}

.admin-action-form input[type="file"] {
  font-size: 0.9rem;
}

.admin-screen .admin-table tbody td:nth-child(2) {
  font-weight: 700;
  color: #165e37;
}

.auth-card {
  max-width: 520px;
  margin: 52px auto;
  padding: 30px;
  position: relative;
  overflow: hidden;
}

.access-card {
  max-width: 920px;
  margin: 48px auto;
}

.access-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  margin-top: 10px;
}

.access-option {
  display: block;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid #cbe7d5;
  background: linear-gradient(180deg, #f7fdf9 0%, #eef8f2 100%);
  text-decoration: none;
  color: #165e37;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.access-option strong {
  display: block;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 1.16rem;
  margin-bottom: 4px;
}

.access-option:hover {
  transform: translateY(-2px);
  border-color: #a8d7bc;
  box-shadow: 0 8px 24px rgba(18, 105, 61, 0.1);
}

@media (min-width: 760px) {
  .access-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.auth-card::before {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(27, 166, 89, 0.24), transparent 60%);
  top: -80px;
  right: -90px;
  pointer-events: none;
}

.auth-note {
  margin-top: 10px;
  font-size: 0.88rem;
}

@media (max-width: 900px) {
  .container {
    width: 96%;
  }

  .topbar .container {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .actions-cell {
    width: 290px;
    min-width: 290px;
  }
}

@media (max-width: 560px) {
  .card {
    padding: 16px;
    border-radius: 14px;
  }

  .auth-card {
    margin: 24px auto;
    padding: 20px;
  }

  .btn {
    width: 100%;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0, 0, 0, 0);
  overflow: hidden;
  white-space: nowrap;
}

/* ===== Metrics Cards ===== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin: 14px 0;
}

.metric-card {
  background: var(--card);
  border: 1px solid #d8efe1;
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.metric-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.metric-link:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 20px 50px rgba(16, 48, 30, 0.14);
  filter: brightness(0.97);
}

.metric-link:active {
  transform: scale(0.98);
  filter: brightness(0.93);
}

.metric-value {
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
}

.metric-label {
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-align: center;
}

.waiting-card  { border-color: #f0d87a; background: #fffdf0; }
.waiting-card  .metric-value { color: #7a5e0d; }
.analyzing-card { border-color: #a8d4f0; background: #f0f8ff; }
.analyzing-card .metric-value { color: #1f5f89; }
.resolved-card { border-color: #b3e8c4; background: #f0fff5; }
.resolved-card .metric-value { color: #1d7a41; }
.urgent-card   { border-color: #f0b3b3; background: #fff5f5; }
.urgent-card   .metric-value { color: #bf2d2d; }
.total-card    { border-color: #c2d8f0; background: #f0f8ff; }
.total-card    .metric-value { color: var(--brand-strong); }
.company-replies-card { border-color: #c9b7f0; background: #f7f3ff; }
.company-replies-card .metric-value { color: #5b3ba8; }

/* ===== Priority badge ===== */
.badge[data-priority="urgente"] {
  background: #fdecea;
  color: #bf2d2d;
}

.badge[data-priority="normal"] {
  background: #f0f0f0;
  color: #555;
}

/* ===== Overdue row ===== */
tr.overdue-row {
  background: #fff5f5 !important;
}

/* ===== Company reply row highlight ===== */
tr.has-company-reply {
  background: #f5f0ff !important;
  border-left: 3px solid #7c4dcc;
}
tr.has-company-reply.overdue-row {
  background: #fff0f5 !important;
}

/* ===== Company reply badge in table cell ===== */
.badge-reply {
  display: inline-block;
  background: #ede7ff;
  color: #5b3ba8;
  border: 1px solid #c9b7f0;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  margin-bottom: 4px;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px 4px;
  flex-wrap: wrap;
}

.pagination-info {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 18, 0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.is-hidden {
  display: none;
}

.modal-box {
  background: var(--card);
  border-radius: 18px;
  padding: 24px;
  width: min(800px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modal-wide {
  width: min(94vw, 1060px);
  height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: 1px solid var(--line);
  font-size: 1rem;
  cursor: pointer;
  color: var(--ink-soft);
  line-height: 1;
  padding: 4px 10px;
  border-radius: 8px;
  margin-top: 0;
}

.modal-close:hover { background: #f0f0f0; }

.pdf-frame {
  flex: 1;
  width: 100%;
  border: none;
  min-height: 65vh;
}

/* ===== Date range filter ===== */
.date-range-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 11px;
}

.date-range-row label { margin-top: 0; }

/* ===== Secondary button ===== */
.btn-secondary {
  background: linear-gradient(140deg, #f5f5f5, #e8e8e8);
  color: #2a5c3f;
  border-color: #ccd8c8;
  box-shadow: none;
}

.btn-secondary:hover {
  background: linear-gradient(140deg, #eeeeee, #e0e0e0);
  filter: none;
  box-shadow: none;
}

/* ===== Reply form (company) ===== */
.reply-collapse.is-hidden {
  display: none;
}

.history-collapse.is-hidden {
  display: none;
}

.title-link {
  border: none;
  background: transparent;
  color: #0d7d42;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.reply-form-wrap {
  padding: 14px 18px;
  background: #f7fdf9;
  border-top: 1px solid #e0efe5;
}

.reply-form {
  display: grid;
  gap: 8px;
  max-width: 700px;
}

.reply-form .btn {
  margin-top: 0;
}

/* ===== Admin action panel ===== */
.action-reply-panel.is-hidden {
  display: none;
}

.compact-reply-form {
  display: grid;
  gap: 6px;
  padding: 10px 0 4px;
}

/* ===== History timeline ===== */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
}

.timeline-item.evt-company  { background: #f5f0ff; border-color: #c9b7f0; }
.timeline-item.evt-resolved { background: #f0fff5; border-color: #b3e8c4; }
.timeline-item.evt-analyzing{ background: #f0f8ff; border-color: #a8d4f0; }
.timeline-item.evt-default  { background: #fafafa; border-color: #dce8dc; }

.tl-icon {
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.tl-body { flex: 1; display: flex; flex-direction: column; gap: 5px; }

.tl-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tl-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(0,0,0,0.06);
  color: var(--ink-soft);
}

.evt-company .tl-badge  { background: #ede7ff; color: #5b3ba8; }
.evt-resolved .tl-badge { background: #d6f5e3; color: #1d7a41; }
.evt-analyzing .tl-badge{ background: #d6eeff; color: #1f5f89; }

.tl-date {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-left: auto;
}

.tl-who {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.tl-status-change {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tl-message {
  font-size: 0.88rem;
  color: var(--ink);
  background: rgba(0,0,0,0.03);
  padding: 6px 10px;
  border-radius: 8px;
  border-left: 3px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
}
