@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap");

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --border: #e8e3dd;
  --text: #2b2d33;
  --text-muted: #71757e;
  --primary: #e2622d;
  --primary-hover: #c94f1f;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(43, 45, 51, 0.06), 0 6px 16px rgba(226, 98, 45, 0.05);
  --shadow-hover: 0 4px 10px rgba(43, 45, 51, 0.08), 0 10px 24px rgba(226, 98, 45, 0.09);
  --font: "Poppins", "Montserrat", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  font-family: var(--font);
  background-color: var(--bg);
  background-image: repeating-linear-gradient(
      135deg,
      rgba(226, 98, 45, 0.045) 0px,
      rgba(226, 98, 45, 0.045) 1px,
      transparent 1px,
      transparent 42px
    ),
    repeating-linear-gradient(
      45deg,
      rgba(43, 45, 51, 0.03) 0px,
      rgba(43, 45, 51, 0.03) 1px,
      transparent 1px,
      transparent 42px
    );
  background-attachment: fixed;
  color: var(--text);
}

h1, h2, h3 {
  letter-spacing: 0.01em;
  font-weight: 600;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 340px;
}

.login-card h1 {
  font-size: 20px;
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

input, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(226, 98, 45, 0.14);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease;
}

.chip:hover {
  border-color: var(--primary);
}

.chip .chip-check {
  display: none;
  font-size: 12px;
}

.chip.chip-selected {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(226, 98, 45, 0.08);
}

.chip.chip-selected .chip-check {
  display: inline;
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease,
    color 0.16s ease, border-color 0.16s ease;
}

.btn-primary {
  background: var(--primary);
  color: var(--text);
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.btn-block {
  width: 100%;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 16px;
}

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

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  white-space: nowrap;
}

th {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-active {
  background: #dcfce7;
  color: var(--success);
}

.badge-inactive {
  background: #f3f4f6;
  color: var(--text-muted);
}

.short-link {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  font-family: "Cascadia Code", monospace;
  color: var(--primary);
  text-decoration: none;
}

/* dentro de tabelas, a largura da célula é indefinida no layout automático,
   então um max-width em % não é respeitado — usamos um valor fixo aqui */
td .short-link {
  max-width: 200px;
}

.short-link:hover {
  text-decoration: underline;
}

.actions-buttons {
  display: flex;
  gap: 6px;
}

.actions-buttons button {
  padding: 6px 10px;
  font-size: 13px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 45, 51, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fade-in 0.18s ease;
}

.hidden {
  display: none !important;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-hover);
  animation: modal-in 0.2s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h2 {
  margin-top: 0;
  font-size: 17px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.utm-box {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}

.utm-box h3 {
  font-size: 13px;
  margin: 0 0 10px 0;
  color: var(--text-muted);
  text-transform: uppercase;
}

.utm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}

.preview-url {
  font-size: 12px;
  word-break: break-all;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  color: var(--text-muted);
  margin-top: -6px;
  margin-bottom: 14px;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
}

.back-link:hover {
  color: var(--text);
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  text-align: center;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

canvas {
  max-width: 100%;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0;
  font-size: 12.5px;
  color: var(--text);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.chart-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  pointer-events: none;
  box-shadow: var(--shadow);
  z-index: 10;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

.qr-preview {
  text-align: center;
}

.qr-preview img {
  max-width: 220px;
  margin: 12px 0;
}

.topnav {
  display: flex;
  gap: 20px;
}

.topnav a {
  position: relative;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding-bottom: 3px;
  transition: color 0.16s ease;
}

.topnav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}

.topnav a:hover {
  color: var(--primary);
}

.topnav a:hover::after {
  transform: scaleX(1);
}

.hint {
  font-weight: 400;
  text-transform: none;
  color: var(--text-muted);
  font-size: 12px;
}

.checkbox-list {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 14px;
}

.checkbox-list label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.checkbox-list input[type="checkbox"] {
  width: auto;
  margin-bottom: 0;
}
