:root {
  --bg: #071018;
  --surface: #0d1724;
  --surface-2: #111f31;
  --surface-3: #162840;
  --border: rgba(148, 163, 184, 0.18);
  --text: #e5edf6;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --brand: #38bdf8;
  --brand-2: #34d399;
  --warning: #f59e0b;
  --danger: #fb7185;
  --success: #34d399;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 0%, rgba(56, 189, 248, 0.14), transparent 30rem),
    linear-gradient(135deg, #071018 0%, #0a1421 46%, #071018 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
}

.login-layout {
  display: grid;
  width: min(430px, 100%);
  gap: 18px;
  justify-items: center;
}

.login-card {
  width: 100%;
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(17, 31, 49, 0.96), rgba(13, 23, 36, 0.96));
  box-shadow: var(--shadow);
}

.brand-logo {
  display: block;
  object-fit: contain;
}

.login-logo {
  width: min(420px, 92%);
  max-height: 210px;
  margin: 0 auto 28px;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.28));
}

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

.header-logo {
  width: 48px;
  height: 48px;
  max-width: none;
  max-height: none;
  border-radius: 8px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.28));
}

.login-card h1 {
  margin-top: 4px;
  font-size: clamp(2rem, 6vw, 2.45rem);
  line-height: 1.05;
}

.login-card p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 13px;
  margin-top: 24px;
}

.login-form .primary-button {
  width: 100%;
  margin-top: 4px;
  min-height: 52px;
}

.login-form input {
  min-height: 48px;
}

.login-card .alert {
  margin: 18px 0 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.title-block {
  max-width: 760px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 999px;
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.1);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 14px;
  color: #f8fafc;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

.title-block p {
  margin-top: 12px;
  color: var(--muted);
  font-size: 1.05rem;
}

.header-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(144px, 1fr));
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  min-width: min(520px, 100%);
}

.connection-card,
.primary-button,
.ghost-button {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

.connection-card {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  background: rgba(17, 31, 49, 0.84);
  box-shadow: var(--shadow);
}

.connection-card > div {
  display: flex;
  align-items: center;
}

.connection-card strong,
.connection-card span:last-child {
  display: block;
}

.connection-card span {
  display: block;
}

.connection-card strong {
  font-size: 0.86rem;
}

.connection-card span:last-child {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
}

.current-user-name {
  margin-top: 6px;
  color: #e0f2fe;
  font-size: 0.76rem;
  font-weight: 800;
}

.current-user-email {
  margin-top: 1px;
  max-width: 210px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-card.is-error .pulse {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(251, 113, 133, 0.12);
}

.pulse {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.12);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  color: #04111d;
  font-weight: 800;
  box-shadow: 0 18px 42px rgba(14, 165, 233, 0.22);
}

.header-actions .primary-button,
.header-actions .ghost-button {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  font-size: 0.92rem;
}

.version-badge {
  grid-column: 1 / -1;
  justify-self: end;
  padding: 4px 9px;
  border: 1px solid rgba(56, 189, 248, 0.32);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(13, 23, 36, 0.72);
  font-size: 0.72rem;
  font-weight: 900;
}

.primary-button:hover {
  filter: brightness(1.06);
}

.primary-button.is-loading .button-icon {
  animation: spin 0.85s linear infinite;
}

.button-icon {
  display: inline-flex;
  width: 18px;
  justify-content: center;
}

.alert {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(251, 113, 133, 0.28);
  border-radius: var(--radius);
  background: rgba(127, 29, 29, 0.34);
  color: #fecdd3;
}

.hidden {
  display: none !important;
}

.main-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(13, 23, 36, 0.84);
  font-weight: 800;
  white-space: nowrap;
}

.tab-button:hover,
.tab-button.is-active {
  border-color: rgba(56, 189, 248, 0.5);
  color: #e0f2fe;
  background: rgba(56, 189, 248, 0.13);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.tab-panel > .panel,
.tab-panel > .summary-grid,
.tab-panel > .charts-grid,
.tab-panel > .report-grid {
  margin-bottom: 18px;
}

.filters-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr)) minmax(260px, 1.35fr);
  gap: 12px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(13, 23, 36, 0.88);
  box-shadow: var(--shadow);
}

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

.report-filters,
.settings-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  padding: 18px;
}

.settings-form .settings-submit {
  align-self: end;
  justify-self: start;
  width: auto;
  min-width: 220px;
}

.form-message {
  margin: 0 18px 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-weight: 800;
}

.form-message.success {
  border: 1px solid rgba(52, 211, 153, 0.28);
  color: #bbf7d0;
  background: rgba(6, 78, 59, 0.28);
}

.form-message.error {
  border: 1px solid rgba(251, 113, 133, 0.28);
  color: #fecdd3;
  background: rgba(127, 29, 29, 0.3);
}

.form-message.warning {
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: #fde68a;
  background: rgba(120, 53, 15, 0.22);
}

.users-admin-panel {
  overflow: hidden;
}

.logged-user-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 14px;
  align-items: center;
  margin: 0 18px 18px;
  padding: 14px 16px;
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: var(--radius);
  background: rgba(8, 47, 73, 0.22);
}

.logged-user-card span {
  grid-row: span 2;
  color: #7dd3fc;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.logged-user-card strong {
  color: #f8fafc;
  font-size: 1rem;
}

.logged-user-card small {
  color: var(--muted);
  font-size: 0.84rem;
}

.users-table {
  min-width: 760px;
}

.users-table-scroll {
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.users-count {
  padding: 14px 24px 18px;
  color: var(--muted);
  font-size: 0.84rem;
}

.table-empty {
  color: var(--muted);
  text-align: center;
}

.user-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  color: #dbeafe;
  background: rgba(148, 163, 184, 0.14);
  font-size: 0.76rem;
  font-weight: 900;
}

.user-status-active {
  color: #bbf7d0;
  background: rgba(16, 185, 129, 0.18);
}

.user-status-suspended,
.user-status-archived {
  color: #fecdd3;
  background: rgba(244, 63, 94, 0.18);
}

.user-status-invited,
.user-status-draft {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.18);
}

.report-filters .search-field {
  grid-column: span 2;
}

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

.compact-button {
  min-height: 38px;
  padding: 0 14px;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: var(--radius);
  outline: none;
  color: var(--text);
  background: #0a1421;
  padding: 0 12px;
}

select:focus,
input:focus {
  border-color: rgba(56, 189, 248, 0.72);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.date-input {
  background-image: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(52, 211, 153, 0.08));
  cursor: pointer;
}

.date-picker-popup {
  position: absolute;
  z-index: 1000;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, 0.26);
  border-radius: var(--radius);
  background: #0d1724;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

.date-picker-head,
.date-picker-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.date-picker-head strong {
  color: #f8fafc;
  font-size: 0.94rem;
  text-transform: capitalize;
}

.date-picker-head button,
.date-picker-foot button,
.date-picker-days button {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  color: var(--text);
  background: rgba(15, 23, 42, 0.92);
}

.date-picker-head button {
  width: 34px;
  height: 34px;
  font-size: 1.25rem;
}

.date-picker-week,
.date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.date-picker-week {
  margin: 12px 0 8px;
}

.date-picker-week span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.date-picker-days button {
  aspect-ratio: 1;
  min-width: 0;
  font-size: 0.86rem;
}

.date-picker-days button:hover,
.date-picker-days button.is-selected {
  border-color: rgba(52, 211, 153, 0.7);
  color: #04111d;
  background: linear-gradient(135deg, #38bdf8, #34d399);
  font-weight: 900;
}

.date-picker-days button.is-today:not(.is-selected) {
  border-color: rgba(56, 189, 248, 0.65);
  color: #bae6fd;
}

.date-picker-foot {
  margin-top: 12px;
}

.date-picker-foot button {
  min-height: 32px;
  padding: 0 10px;
  color: #bae6fd;
}

input::placeholder {
  color: var(--muted-2);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  position: relative;
  min-height: 130px;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(17, 31, 49, 0.94), rgba(13, 23, 36, 0.94));
  box-shadow: var(--shadow);
  text-align: left;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.metric-card:hover {
  border-color: rgba(56, 189, 248, 0.56);
  background: linear-gradient(180deg, rgba(22, 40, 64, 0.98), rgba(13, 23, 36, 0.98));
  transform: translateY(-2px);
}

.metric-card:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.28);
  outline-offset: 3px;
}

.metric-card.is-active {
  border-color: rgba(52, 211, 153, 0.78);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(52, 211, 153, 0.24) inset;
}

.metric-card.is-active::before {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(52, 211, 153, 0.12);
  content: "";
}

.metric-card::after {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  content: "";
  opacity: 0.2;
}

.metric-card.neutral::after { background: var(--brand); }
.metric-card.warning::after { background: var(--warning); }
.metric-card.info::after { background: #38bdf8; }
.metric-card.success::after { background: var(--success); }
.metric-card.danger::after { background: var(--danger); }

.metric-card span {
  display: block;
  max-width: 190px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.metric-card strong {
  display: block;
  margin-top: 18px;
  color: #f8fafc;
  font-size: clamp(1.45rem, 2.4vw, 2.35rem);
  line-height: 1;
}

.report-summary-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.report-card-static {
  cursor: default;
}

.report-card-static:hover {
  transform: none;
}

.executive-panel,
.attention-panel,
.settings-panel {
  margin-bottom: 18px;
}

.executive-summary {
  padding: 18px;
  color: #cbd5e1;
  line-height: 1.6;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.stats-grid,
.attention-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
}

.stats-card,
.attention-item {
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.52);
}

.stats-card h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

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

.stats-card dt,
.attention-item span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stats-card dd,
.attention-item strong {
  display: block;
  margin: 4px 0 0;
  color: #f8fafc;
  font-size: 1.05rem;
}

.wide-chart {
  grid-column: span 2;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(13, 23, 36, 0.9);
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 18px;
}

.panel-heading h2 {
  color: #f8fafc;
  font-size: 1rem;
  letter-spacing: 0;
}

.panel-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
}

.chart-panel {
  min-height: 360px;
}

.chart-wrap {
  height: 292px;
  padding: 18px;
}

.table-panel {
  overflow: hidden;
}

.table-heading {
  align-items: flex-start;
  padding-bottom: 16px;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.ghost-button {
  min-height: 34px;
  padding: 0 12px;
  background: rgba(15, 23, 42, 0.88);
}

.logout-button {
  min-height: 44px;
  padding: 0 16px;
}

.ghost-button:hover:not(:disabled) {
  border-color: rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1240px;
  border-collapse: collapse;
}

th,
td {
  padding: 16px 22px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  text-align: left;
  vertical-align: middle;
}

th:first-child,
td:first-child {
  padding-left: 26px;
}

th {
  color: var(--muted);
  background: rgba(15, 23, 42, 0.46);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  color: #dbeafe;
  font-size: 0.9rem;
}

tbody tr:hover {
  background: rgba(56, 189, 248, 0.05);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-aguardando_humano {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.status-respondido {
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.24);
}

.status-resolvido {
  color: #bbf7d0;
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.24);
}

.status-unknown {
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(56, 189, 248, 0.26);
  border-radius: var(--radius);
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.1);
  font-weight: 800;
  text-decoration: none;
}

.open-link:hover {
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(56, 189, 248, 0.18);
}

.empty-state {
  margin: 0 18px 18px;
  padding: 28px;
  border: 1px dashed rgba(148, 163, 184, 0.24);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: rgba(15, 23, 42, 0.36);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #08111d;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid #08111d;
  border-radius: 999px;
  background: #334155;
}

*::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

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

@media (max-width: 1180px) {
  .filters-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-filters,
  .settings-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-form .settings-submit {
    width: 100%;
    min-width: 0;
  }

  .search-field {
    grid-column: span 2;
  }

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

  .report-summary-grid,
  .stats-grid,
  .attention-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 28px, 1480px);
    padding-top: 22px;
  }

  .page-header {
    display: grid;
  }

  .header-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
    min-width: 0;
  }

  .connection-card,
  .header-actions .primary-button,
  .header-actions .ghost-button {
    min-width: 0;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .filters-panel,
  .summary-grid,
  .report-filters,
  .settings-form,
  .report-summary-grid,
  .stats-grid,
  .attention-grid {
    grid-template-columns: 1fr;
  }

  .search-field {
    grid-column: auto;
  }

  .report-filters .search-field,
  .wide-chart {
    grid-column: auto;
  }

  .export-actions {
    width: 100%;
    justify-content: stretch;
  }

  .export-actions button {
    flex: 1 1 100%;
  }

  .header-actions {
    grid-template-columns: 1fr;
  }

  .table-heading,
  .pagination-actions {
    display: grid;
    width: 100%;
  }

  .pagination-actions {
    grid-template-columns: 1fr auto 1fr;
  }
}
